yibn2008 / fast-sass-loader

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

@import external files don't work like sass #73

Open ArTiSTiX opened 2 years ago

ArTiSTiX commented 2 years ago

Sass allows fallback to the behaviour of css @import, and allows to compile @import statements to plain CSS statements.

From the doc, sass will transpile to plain css for:

Looks ok for url(), and seems legit for .css since it's a feature of fast-sass-loader (i think). But using urls starting with protocol, e.g. http:// will break with fast-sass-loader. I think it may also breaks for imports inside media queries.

@import "https://fonts.googleapis.com/css?family=Playfair+Display:400i";

will raise

ERROR in /myFile.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
HookWebpackError: Module build failed (from ./node_modules/fast-sass-loader/lib/index.js):
Error: import file cannot be resolved: "@import "https://fonts.googleapis.com/css?family=Playfair+Display:400i";" @/myFile.scss
    at Object.importReplacer (x/node_modules/fast-sass-loader/lib/index.js:229:21)

It is working if using @import url("https://fonts.googleapis.com/css?family=Playfair+Display:400i"); but since i'm trying to implement a standard config of Stylelint, it forces me to ignore the import-notation rule that disallow using the url syntax.