Segui o processo mas acredito que perdi algum detalhe porque ao rodar npm run build-prod não minifica o arquivo styles.css.
const path = require('path');
const babiliPlugin = require('babili-webpack-plugin');
const extractTextPlugin = require('extract-text-webpack-plugin');
const optimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); //minifica o css adicional
let plugins = [];
plugins.push(new extractTextPlugin('styles.css'));
if (process.env.NODE_ENV == 'production'){ //Se a variavel de ambiente é production, seta os plugins do babilinp minificaro bundle.
plugins.push(new babiliPlugin());
plugins.push(new optimizeCSSAssetsPlugin({
cssProcessor: require('cssnano'),
cssProcessorOptions: {
discardComments: {
removeAll: true //remove comentarios ao minificar
}
},
canPrint: true
}));
e o package.json:
"cssnano": "^3.10.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^0.11.2",
"optimize-css-assets-webpack-plugin": "^2.0.0",