andreyfedoseev / django-static-precompiler

Django Static Precompiler provides template tags and filters to compile CoffeeScript, LiveScript, SASS / SCSS, LESS, Stylus, Babel and Handlebars. It works with both inline code and external files.
Other
222 stars 60 forks source link

compilestatic broken on windows directory names. #121

Closed shaladi closed 1 year ago

shaladi commented 5 years ago

I discovered this bug while running on windows. In compilestatic.py (lines 29 and 30) it does this:

if path.startswith("/"):
    path = path[1:]

This obviously wouldn't work for windows because it uses backslashes. And I was hitting a bug down the line where os.path.join was returning an absolute path instead of merging it with STATIC_ROOT.

I added the fix for this case as:

if path.startswith("/") or path.startswith("\\"):
    path = path[1:]

Which fixed the problem. But I noticed this assumption of the unix separator is done in more places (e.g. watch.py) in the codebase and may require a bigger refactoring to make sure everything works on windows.

andreyfedoseev commented 3 years ago

Hello @shaladi

Could you provide some sample code of how you use the compile template filter?