I just figured it out. We should be using Sass Modules instead of @import. Also, this video helped me a lot: https://www.youtube.com/watch?v=CR-a8upNjJ0
When I replaced @import with @use it started working.
Webpack 5 sass-loader not compiling nested scss files - Stack Overflow
Are there any sass loaders that work with webpack 4?
sass-loader doesn't work with :root declarations or css custom props
css/sass loader not working with regular import, but fine with inline loaders.
Videos
I just figured it out. We should be using Sass Modules instead of @import. Also, this video helped me a lot: https://www.youtube.com/watch?v=CR-a8upNjJ0
When I replaced @import with @use it started working.
this is my configs object for scss, and it's working with import.
You would need to install autoprefixer and add a css-loader and a style-loader loaders
{
test: /\.scss$/i,
use: [{
// inject CSS to page
loader: 'style-loader'
}, {
// translates CSS into CommonJS modules
loader: 'css-loader'
}, {
// Run postcss actions
loader: 'postcss-loader',
options: {
// `postcssOptions` is needed for postcss 8.x;
// if you use postcss 7.x skip the key
postcssOptions: {
// postcss plugins, can be exported to postcss.config.js
plugins: function () {
return [
require('autoprefixer')
];
}
}
}
}, {
// compiles Sass to CSS
loader: 'sass-loader'
}]
},
Hi, I'm painfully new to webpack. I'm starting right off the bat with webpack 4, and I understand the concept of input/output.
I understand the concept of loaders/plugins too (at a very basic level) but sass-loader seems to rely on something called extract-text-webpack-pluginwhich isn't supported in webpack 4.
How are webpack 4 users getting around this? Surely Sass support is an essential feature for most developers...