14 March 2017

You can achieve this by adding a library that supports css minify to "webpack.config.js". In this snippet I use "optimize-css-assets-webpack-plugin" which uses cssnano for minimizing by default. The "safe" parameter is set so the output css would not reset z-indexes.

Source code viewer
  1. const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
  2.  
  3. if (process.env.NODE_ENV === 'production') {
  4. config.plugins.push(
  5. new ExtractTextPlugin('styles.css'),
  6. new OptimizeCssAssetsPlugin({
  7. cssProcessorOptions: {
  8. safe: true,
  9. },
  10. })
  11. );
  12. }
Programming Language: ECMAScript