What is exactly the importLoaders option of css-loader in Webpack 4?

After more searching it turned out that I’m not the only one confused about how to use this option correctly. Issues from the GitHub repo of css-loader:

https://github.com/webpack-contrib/css-loader/issues/765

Also see @guidobouman excellent explanation here:
https://github.com/webpack-contrib/css-loader/issues/228#issuecomment-312885975

So this answers my question (quoted literally):

importLoaders only has effect on unresolved @imports. So when using
postCSS with nextCSS (no @import resolver) you’ll want to set
importLoaders. This way nextCSS will also be applied to imported .css
files. But when using sass, it already handles the @import statements,
so no importLoaders is required.

So, this only happens when css-loader finds an unresolved @import.
When using sass-loader for example; All imports are resolved (and
concatenated) before css-loader even gets the chance to look for an
@import.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)