Kronuz / pyScss

pyScss, a Scss compiler for Python
MIT License
582 stars 140 forks source link

Nested relative imports not working #358

Open pszalanski opened 8 years ago

pszalanski commented 8 years ago

If I have an scss file which imports another scss file with a relative path, the compilation fails. I wrote a small example script:

make.py

import scss
scss.compiler.compile_file("test.scss")

test.scss

@import "./button/buttons.scss";

button/buttons.scss

@import "./label/labels.scss";

button/label/labels.scss

div {
    color: red;
}

I think this is supposed to work, isn't it? The relative paths should be resolved, starting from the file that contains the import statement.

nlessmann commented 5 years ago

This appears to be a Windows problem.

In CoreExtension.handle_import, the value of rule.source_file.relpath is a PurePosixPath object, but does contain a backslash instead of a forward slash for the second import (so when trying to import labels/labels.scss the path will be button\label/labels.scss).

I don't know where to fix this, but a quick and dirty hack in this function that replaces the backslash with a forward slash makes it work. Probably the path needs to be normalized to a posix path somewhere before.