-
Notifications
You must be signed in to change notification settings - Fork 42
/
webpack.prod.js
32 lines (29 loc) · 1.18 KB
/
webpack.prod.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*global require: false, module: false, process: false */
var webpack = require('webpack');
var config = require('./webpack.config');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserJSPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
delete config.entry.docs; // Remove docs from production build.
config.mode = 'production';
config.output.filename = "[name].[chunkhash].js";
config.output.chunkFilename = "[chunkhash].bundle.js";
console.log(config.optimization);
config.optimization = {
minimizer: [
new TerserJSPlugin({cache: true, parallel: true, sourceMap: true}),
new OptimizeCSSAssetsPlugin({})]
};
config.plugins = config.plugins.concat([
new MiniCssExtractPlugin({
filename: '[name].[contenthash].css'
}),
/* new webpack.optimize.CommonsChunkPlugin({name: 'init', filename: "init.[chunkhash].js"}) */
]);
// Amend css loaders with MiniCssExtractPlugin.
config.module.rules.forEach(function (rule) {
if (rule.use && rule.use[0] && rule.use[0].loader === 'style-loader') {
rule.use = [MiniCssExtractPlugin.loader].concat(rule.use.slice(1));
}
});
module.exports = config;