-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.js
29 lines (28 loc) · 1016 Bytes
/
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
const merge = require("webpack-merge");
const common = require("./webpack.common.js");
const webpack = require("webpack");
const PrerenderSPAPlugin = require('prerender-spa-plugin')
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
module.exports = merge(common, {
mode: "production",
devtool: 'source-map',
plugins: [
new webpack.HashedModuleIdsPlugin(),
new OptimizeCSSAssetsPlugin({
assetNameRegExp: /\.css$/g,
cssProcessor: require('cssnano'), //引入cssnano配置压缩选项
cssProcessorOptions: {
discardComments: { removeAll: true }
},
canPrint: true //是否将插件信息打印到控制台
}),
new PrerenderSPAPlugin({
// Required - The path to the webpack-outputted app to prerender.
staticDir: path.join(__dirname, 'dist'),
// Required - Routes to render.
routes: ['/'],
}),
new BundleAnalyzerPlugin(),
]
});