yibn2008 / fast-sass-loader

High performance sass loader for webpack
250 stars 38 forks source link

Overzealous dedupe #29

Closed d4rky-pl closed 6 years ago

d4rky-pl commented 6 years ago

The deduplication algorithm is also deduping nested imports, resulting in broken/wrong CSS.

Full description of the problem Let's say we have two SCSS files: `style.scss` which is our main file and `group.scss` which contains a bunch of generic rules. We now want those rules to be imported under a class: ``` .a { @import 'group' } ``` *This will work as expected* and the resulting file will look for ex. like this: ``` .a .c { color: red } ``` Unfortunately if we try to do it in more than one place, the dedupe algorithm will wrongly assume we don't need to import the same file multiple times and silently break our CSS: ``` .a { @import 'group' } .b { @import 'group' } ``` The above code will result in broken: ``` .a .c { color: red } /* .b is missing because it didn't contain any rules */ ```

I've created a repository from above example. I believe deduping @import should only work if it's in root of the document and not when it's nested.

yibn2008 commented 6 years ago

en ... I will add a warning for nested imports.