webpack fails “module build failed: unknown word” with webpack.config.js file

ぐ巨炮叔叔 提交于 2019-12-01 19:48:19

In webpack, when you list multiple loaders within a rule, they are evaluated from right to left (in your case, bottom to top), so your scss rule should be:

  {
    test: /\.(s*)css$/,
    use: [
      'style-loader',
      'css-loader',
      'sass-loader'
    ]
  }

The reason is that first, you want your sass to compile to css, and then the css will be inlined in your html file via the style-loader.

Also, if you are not using sass, you can remove the sass-loader.

Have check these issues getting similar issues in my web pack project You have to check the web pack rule :

{
    test: /\.(s*)css$/,
    use: [
      'style-loader',
      'css-loader',
      'sass-loader'
    ]
  }

Above, updated the rule it will handle our sass or CSS files. The test is test: /.(s*)css$/ : which means any file having name matching with regular expression /.(s*)css$/i.e. .scss or .css

It should be compiled with the chain of loaders specified in the use array i.e. ['style-loader', 'css-loader', 'sass-loader'].

This rule chain the output of sass-loader to css-loader. css-loader will take this css output of sass-loader and will also process any other .css files we have in our application and pass on the .css to style-loader, which will then do the job of putting the css codes inside tags in our index.html,It work bottom to top..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!