TLDR; Scroll to the bottom for the answer or combine both Webpack and Dart Sass VM. https://github.com/sass/dart-sass/releases/
Not sure if anyone else has run into this issue, but my first save while the files are being watched can take up 6-7 seconds ( 6720 ms ).
It then dips between 2-3.5 seconds typically.
I'm using Webpack 5, latest version of sass-loader and sass. I also included Fibers per Webpacks recommendation and I'm really not seeing any improvement.
My JS compiles in less than a second.
I've also tried both memory and filesystem setting in Webpack cache as well. I also tried cache-loader.
My current SCSS rules look like this:
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const Fiber = require('fibers');
const Sass = require('sass');
const config = require('../app.config');
module.exports = {
rules: [{
test: /\.s[ac]ss$/,
exclude: /node_modules/,
include: config.paths.sass,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: { sourceMap: true },
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
config: path.resolve(__dirname, '../postcss.config.js'),
},
}
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
sassOptions: {
fiber: Fiber
},
}
}
]
}]
};
My browser support for postcss is:
module.exports = {
plugins: {
'postcss-preset-env': {
stage: 0,
browsers: ['last 2 versions', 'not dead', '> 0.2%']
},
}
};