Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output caching is effectively disabled in Windows #64

Closed
frostbtn opened this issue Jun 6, 2017 · 6 comments
Closed

Output caching is effectively disabled in Windows #64

frostbtn opened this issue Jun 6, 2017 · 6 comments

Comments

@frostbtn
Copy link
Contributor

frostbtn commented Jun 6, 2017

sass_processor.processor.SassProcessor.is_latest has this code:

           components = os.path.normpath(srcfilename).split(os.path.sep)
           srcfilename = ''.join([os.path.sep + c for c in components if c != os.path.pardir])

And this os.path.sep inside the join makes a priori invalid path in Windows (like /d:/path/path), so os.path.isfile what follows always returns False, forcing full compilation on every page request (when SASS_PROCESSOR_ENABLED is True, i.e. in development).

I can't seem to track down why this code is here. Does libsass generate some strange paths in their map file?

Removing these lines makes everything work as expected... in Windows. I have no easy way to test it on *nix, hence the question.

@jrief
Copy link
Owner

jrief commented Jun 6, 2017

In the generated sourcemap file, does libsass use / or \ in paths?
If it's a normal slash /, then this problem could be solved by replacing the first line against

components = os.path.normpath(srcfilename).split('/')

Please check, since I have no Windows machine to test.

@frostbtn
Copy link
Contributor Author

frostbtn commented Jun 6, 2017

libsass generates this:

	"sources": [
		"d:/Projects/py/project/scss/static/project.scss",
		"d:/Projects/py/project/scss/_bootstrap-custom.scss", 

Ok, first line could be changed. What about that first os.path.sep on the second line. It's what makes path invalid on Windows.

Generally, what libsass generates in the source map is already ok to check with os.path.* (down the code). Is libsass generates something strange on Linux? Some relative paths? Could you give an example, should you happen to have a minute for this. I may come up with a fix, I just can't figure out what problem unknown to me is being worked around in these lines.

(libsass's source map is pretty useless with this kind of paths on Windows, as Chrome tries to open something like https://server/d:/Projects/py/project/scss/static/project.scss and this can never be correct. It's a libsass problem for sure, but nobody care, me included. However, 1.5 seconds per page request is a problem, I suppose).

@jrief
Copy link
Owner

jrief commented Jun 6, 2017

My development environment ist MacOSX, and there libsass creates entries such as

...
"sources": [
    "../../../Users/jrief/Workspace/djangoSHOP/django-shop/example/myshop/static/myshop/css/default.scss",
    "../../../Users/jrief/Workspace/djangoSHOP/django-shop/shop/static/shop/css/_django-shop.scss",
    "../../../Users/jrief/Workspace/djangoSHOP/django-shop/shop/static/shop/css/_variables.scss",
    ...
],
...

That's btw. the reason why I have to remove the ../../.. in front of /Users/. os.path.abspath() unfortunately doesn't work here.

@frostbtn
Copy link
Contributor Author

frostbtn commented Jun 6, 2017

Oh, I see. That's make sense now. A total mess on libsass's end.
I shall take a deeper look, if the time will allow.
Let's leave this issue open for the time, maybe someone may have more input.

@jrief
Copy link
Owner

jrief commented Jul 23, 2017

@frostbtn have you been able to find a fix on Windows?

@frostbtn
Copy link
Contributor Author

I found no easy and safe way to fix it, unfortunately. I don't think I will have more input on this issue in the nearest future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants