Kronuz/pyScss

Nested relative imports not working

pszalanski opened this issue · 1 comments

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.

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.