7

I have a minimal webpack setup and using sass, css and style loaders to compile sass in my project. Everything works fine but I can't understand why when I run webpack -p I get some style-loader functions in my bundle:

enter image description here

As you can see node-modules are included for some reason, basically to include style-loader and css-loader. Is it normal? Do these functions have a purpose ?

H3AR7B3A7
  • 4,366
  • 2
  • 14
  • 37
ciaoben
  • 3,138
  • 4
  • 27
  • 42

1 Answers1

0

I believe it's because style-loader itself is declared not to be used in production.

"For production builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on. This can be achieved by using the mini-css-extract-plugin, because it creates separate css files. For development mode (including webpack-dev-server) you can use style-loader, because it injects CSS into the DOM using multiple and works faster."

https://webpack.js.org/loaders/style-loader/

I would check your webpack config for development and production, likely the rule for the using style-loader is not present.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 07 '22 at 04:32