Webpack sass where is the css file

后端 未结 3 1201
说谎
说谎 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
    慢半拍i (楼主)
    2021-01-30 16:29

    The extract-text-webpack-plugin has been deprecated you should use the mini-css-extract-plugin. Assuming you have your styles in css/app.scss, your entry file should import it as usual like:

    import 'css/app.scss';
    

    Add the plugin:

    plugins: [new MiniCssExtractPlugin()]
    

    And add the plugin to your loader chain:

    {
      test: /\.s[ac]ss$/i,
      use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
    }
    

    When you run webpack with that configuration you'll end up with an app.css file loaded in your HTML with a tag similar to:

    
    

提交回复
热议问题