Webpack sass where is the css file

后端 未结 3 1198
说谎
说谎 2021-01-30 15:52

I am using web pack with sass loader like this:

module.exports = {
  module: {
    loaders: [
      {
        test: /\\.scss$/,
        loader: \"style!css!sass\         


        
3条回答
  •  梦毁少年i
    2021-01-30 16:44

    By default, the style-loader inlines the compiled css into your bundle, which are added to the head of the page with the output file e.g. bundle.js. Using the extract-text-webpack-plugin you can remove the compiled css from the bundle, and export it to a separate file.

    First - wrap your loader in the plugin:

     loaders: [{
      test: /\.scss$/,
      loader: ExtractTextPlugin.extract(
        "style",
        "css!sass")
     }]
    },
    

    Then tell the plugin what to call the file it generates:

    plugins: [
        new ExtractTextPlugin("app.css")
     ]
    

    Include this file in your HTML normally.

提交回复
热议问题