yibn2008 / fast-sass-loader

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

*.import.scss not being preferred when using dart sass with fast-sass-loader #70

Open dcwarwick opened 3 years ago

dcwarwick commented 3 years ago

Dart sass supports the new modules system, and when it encounters @import "X" should prefer X.import.scss to X.scss.

We are using this to maintain support for users of our library who may not have moved to dart sass yet, or may be using an old version, by creating X.import.scss files in parallel to X.scss files and using new sass features only in the X.import.scss files. So, for example, we have some functions in an X.scss file that use / for division, and the X.import.scss file replaces the / with math.div, which wouldn't work for node-sass users while the / would cause deprecation warnings for dart sass users. This is along the lines of what Natalie describes here: https://github.com/patternfly/patternfly/issues/4096#issuecomment-859055362

When I compile our scss with sass directly, we get no deprecation warnings, because wherever we have these X.import.scss files they are being preferred to the old X.scss files. However, when I build our scss into a Webpack 5 bundle, we get a whole slew of deprecation warnings. It looks like the X.scss files are being used and the X.import.scss file ignored.

Does fast-sass-loader support this behaviour of dart sass, to prefer X.import.scss to X.scss? If not, this is a request for that feature please. If it does, maybe I've done something wrong to break this in my Webpack build -- any ideas as to what I might have done would be gratefully received!

dcwarwick commented 3 years ago

btw, here is the Webpack config we're using. It's inside storybook, just to make things more complicated: image We're using webpack 5.57.1, and fast-sass-loader 2.0.0 with sass 1.42.1.