8

I use this config for my webpack 2

        {
            test: /\.css$/i,
            use: ExtractTextPlugin.extract({
                use: 'css-loader?minimize'
            })
        }

How to remove all comments based on string mode ? I use this but does not work

  'css-loader?minimize&{discardComments:{removeAll:true}}'

Can anyone help me ?

HamedFathi
  • 3,667
  • 5
  • 32
  • 72

2 Answers2

3

You could use optimize-css-assets-webpack-plugin to remove comments: example

-2

Might as well keep going and add SASS in there also. Here is our config.

const style_loader = ExtractTextPlugin.extract({
  fallback: 'style-loader',
  use: [
    { loader: 'css-loader',
      options: {
        sourceMap: true
      }
    },
    { loader: 'postcss-loader',
      options: { plugins() { return [Autoprefixer]; } }
    },
    { loader: 'resolve-url-loader' },
    { loader: 'sass-loader',
      options: { sourceMap: true }
    }
  ]
});

Define that above and then below in your rules you can have:

{
    test: /\.scss$/,
    use: style_loader
}

Then when you add your plugins:

new ExtractTextPlugin('[name].css'),

I would import one main.scss file into your whatever .js file is your entry point and then import your _partial.scss files into the main.scss file. That way you can break up your styles and start using all of the sass features also.

jaruesink
  • 1,205
  • 2
  • 14
  • 24