I do not work with Webpack itself but I know the effect from others ... there are three things to think about:

  1. Sass becomes slowly as many SASS files are included to the process. Big SASS-Frameworks tend to use a lot of files and latest when you use a lot of big modules it heavily could slow down at all. Sometimes there are more modules included than needed.

  2. Often the standard project settings try to to a lot of work at the same time. I.e. writing min-files in same process simply doubles the time. If it is that: just prepare 'min-files' at the end of your work. Up to that using additonal post-processors to autoprefix like linters and maby postcss needs extra time ... which counts doubles when writing min-files at once...

  3. JS-Sass-Compilers are slower at all. So you can save time using native SASS direct. This may not be handsome but in big projects that helped me a lot. If you may try that here the link to information how to install: https://sass-lang.com/install

Just ideas for thinking forward...

Answer from Brebber on Stack Overflow
🌐
npm
npmjs.com › package › fast-sass-loader
fast-sass-loader - npm
Blazingly fast sass loader for webpack.
      » npm install fast-sass-loader
    
Published   Nov 18, 2021
Version   2.0.1
Author   yibn2008
🌐
GitHub
github.com › yibn2008 › fast-sass-loader
GitHub - yibn2008/fast-sass-loader: High performance sass loader for webpack
Blazingly fast sass loader for webpack.
Starred by 250 users
Forked by 38 users
Languages   SCSS 96.7% | JavaScript 3.3% | SCSS 96.7% | JavaScript 3.3%
Top answer
1 of 3
1

I do not work with Webpack itself but I know the effect from others ... there are three things to think about:

  1. Sass becomes slowly as many SASS files are included to the process. Big SASS-Frameworks tend to use a lot of files and latest when you use a lot of big modules it heavily could slow down at all. Sometimes there are more modules included than needed.

  2. Often the standard project settings try to to a lot of work at the same time. I.e. writing min-files in same process simply doubles the time. If it is that: just prepare 'min-files' at the end of your work. Up to that using additonal post-processors to autoprefix like linters and maby postcss needs extra time ... which counts doubles when writing min-files at once...

  3. JS-Sass-Compilers are slower at all. So you can save time using native SASS direct. This may not be handsome but in big projects that helped me a lot. If you may try that here the link to information how to install: https://sass-lang.com/install

Just ideas for thinking forward...

2 of 3
0

I have a real small prototype project with a maybe two page long styles.sass and my dev build with eval etc. took 16s. That was way too high.

I tried the cache-loader solution and it only supports webpack 4.0 and I use webpack 5.0.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/webpack
npm ERR!   dev webpack@"^5.75.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^4.0.0" from [email protected]
npm ERR! node_modules/cache-loader
npm ERR!   dev cache-loader@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:

Then I found a fast-sass-loader node module which is also not maintained anymore.

Like in life the simplest solution are always the best. Don't use SASS as at all. I replaced my sass file with a scss file. With a relative small effort my build went from 16s to 7s and I haven't even optimized anything in the packaging yet.

I'm quite sure your reload time goes down dramatically as well, the moment you replace every sass file with a scss one.

🌐
webpack
webpack.js.org › loaders › sass-loader
sass-loader | webpack
Loads a Sass/SCSS file and compiles it to CSS. ... To enable CSS processing in your project, you need to install style-loader and css-loader via npm i style-loader css-loader.
🌐
GitHub
github.com › webpack-contrib › sass-loader › issues › 848
The ways to improve speed · Issue #848 · webpack/sass-loader
April 29, 2020 - I'm having speed issue for sass-loader, so I looked for how to solve this speed issue. There were two ways. Use fast-sass-loader Use happypack/thread-loader What is the most efficient way in cu...
Published   May 31, 2020
Author   baeharam
🌐
Stack Overflow
stackoverflow.com › questions › 56262137 › slow-sass-loader-build-times-with-webpack
Slow sass-loader Build Times with Webpack - Stack Overflow
Replace sass-loader with fast-sass-loader - Many people recommended this, but when I got it to work, it didn’t seem to change the build time at all.
🌐
GitHub
github.com › symfony › webpack-encore › issues › 258
Replace Sass Loader with Fast Sass Loader · Issue #258 · symfony/webpack-encore
December 1, 2017 - Hey folks, how can I replace the default sass-loader with another implementation like https://github.com/yibn2008/fast-sass-loader? It's possible via the API from Symfony Encore?
Author   xyNNN
🌐
npm
npmjs.com › package › @4c › fast-sass-loader
@4c/fast-sass-loader - npm
Blazingly fast sass loader for webpack.
      » npm install @4c/fast-sass-loader
    
Published   Apr 29, 2020
Version   2.2.0
Author   yibn2008
🌐
GitHub
github.com › yibn2008 › fast-sass-loader › issues › 3
Please provide a performance test · Issue #3 · yibn2008/fast-sass-loader
HI yibn2008 thanks for providing an alternative solution. I'm one of the maintainers of sass-loader and I think it's great to see where we can get better. Could you please provide a performance test that proves your performance numbers? ...
Find elsewhere
🌐
CodeSandbox
codesandbox.io › examples › package › fast-sass-loader
fast-sass-loader examples - CodeSandbox
Use this online fast-sass-loader playground to view and fork fast-sass-loader example apps and templates on CodeSandbox.
Top answer
1 of 2
6

I encountered the same issue with sass-loader and tried a few solutions but the best solution was to use cache-loader
Now my build went down from 27s to just 10s

Before

After

Install:
npm i -D cache-loader

Usage:

{
  test: /\.(sa|sc|c)ss$/,
  use: [
    {
      loader: MiniCssExtractPlugin.loader,
      options: {
        publicPath: "../",
        hmr: hotMode,
        reloadAll: true,
      },
    },
    // do not insert cache-loader above the extract css loader, it may cause issues
    "cache-loader", // <--------
    "css-loader?url=false",
    "postcss-loader",
    {
      loader: "sass-loader",
      options: {
        sassOptions: {
          hmr: true,
          modules: true,
          includePaths: [
            path.join(__dir, "/views/scss/theme/"),
          ]
        }
      }
    },
  ],
}
2 of 2
0

I have a real small prototype project with a maybe two page long styles.sass and my dev build with eval etc. took 16s. That was way too high.

I tried the cache-loader solution above and it only supports webpack 4.0 and I use webpack 5.0.

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/webpack
npm ERR!   dev webpack@"^5.75.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^4.0.0" from [email protected]
npm ERR! node_modules/cache-loader
npm ERR!   dev cache-loader@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:

Then I found a fast-sass-loader node module which is also not maintained anymore.

Like in life the simplest solution are always the best. Don't use SASS as at all. I replaced my sass file with a scss file. With a relative small effort my build went from 16s to 7s and I haven't even optimized anything in the packaging yet.

🌐
Medium
rhum1-dev.medium.com › angular-10-how-to-optimize-scss-compilation-826ac5cc7ba3
Angular, how to optimize scss compilation | by Rhumain Vermo | Medium
February 22, 2021 - After analyzing the cpu node consumption, I noticed that the modules used by angular-cli to transpile the scss to css were sass-loader and url-resolve-loader. ... After some research, I found the fast-sass-loader transpiler which now replaces sass-loader and url-resolve-loader.
🌐
GitHub
github.com › yuhaoju › fast-sass-loader
GitHub - yuhaoju/fast-sass-loader: High performance sass loader for webpack 1/2
High performance sass loader for webpack 1/2. Contribute to yuhaoju/fast-sass-loader development by creating an account on GitHub.
Forked by 44 users
Languages   JavaScript 100.0% | JavaScript 100.0%
🌐
GitHub
github.com › yibn2008 › fast-sass-loader › issues
yibn2008/fast-sass-loader
High performance sass loader for webpack. Contribute to yibn2008/fast-sass-loader development by creating an account on GitHub.
Author   yibn2008
🌐
GitHub
github.com › yibn2008 › fast-sass-loader › issues › 9
includePaths do not work as expected · Issue #9 · yibn2008/fast-sass-loader
When working with the includePaths options I encounter some issues. Let's say I'd like to use the styles of a library loaded via npm dependency. I'd write an import statement like this, knowing tha...
🌐
Snyk
snyk.io › advisor › fast-sass-loader › fast-sass-loader code examples
Top 5 fast-sass-loader Code Examples | Snyk
Learn more about how to use fast-sass-loader, based on fast-sass-loader code examples created from the most popular ways it is used in public projects
🌐
GitHub
github.com › yibn2008 › fast-sass-loader › issues › 39
unable to resolve @import paths in scss files. · Issue #39 · yibn2008/fast-sass-loader
July 24, 2018 - 'style-loader' : MiniCssExtractPlugin.loader, { loader: 'css-loader', options: { sourceMap: false, include: path.resolve(__dirname, '../', './src'), }, }, { loader: 'postcss-loader', options: { sourceMap: false, include: path.resolve(__dirname, '../', './src'), plugins() { return [autoprefixer('last 2 versions', 'ie 10')]; }, }, }, AntdScssThemePlugin.themify({ loader: 'fast-sass-loader', options: { sourceMap: false, include: path.resolve(__dirname, '../', './src'), data: '@import "./src/Styles/themes/core";@import "./src/Styles/themes/anttheme";', }, }), ], },
Author   hannadrehman