-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathwebpack.prod.js
More file actions
75 lines (74 loc) · 1.86 KB
/
webpack.prod.js
File metadata and controls
75 lines (74 loc) · 1.86 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const path = require('path')
const merge = require('webpack-merge')
const common = require('./webpack.common.js')
const SimpleProgressWebpackPlugin = require( 'simple-progress-webpack-plugin') // 打包进度条
const CleanWebpackPlugin = require('clean-webpack-plugin')
const HtmlWebpackPlugin = htmlWebpackPlugin = require('html-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = merge(common, {
mode: 'production',
output: {
path: path.resolve(__dirname, 'docs'),
publicPath: '/page-design/',
filename: '[name]_[hash:8].js'
},
module: {
rules: [{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['babel-preset-env']
}
}
}]
},
plugins: [
new CleanWebpackPlugin(
['dist/*', 'docs/*'],
{ verbose: true, dry: false, }
),
new SimpleProgressWebpackPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/html/index.html',
inject: true,
chunks: ['main'],
// 路径源修改
static: '/',
timestamp: new Date().getTime(),
minify: {
//删除html的注释
removeComments: true,
//删除空格
collapseWhitespace: true
}
}),
new BundleAnalyzerPlugin()
],
optimization: {
splitChunks: {
chunks: 'all',
minSize: 30000,
maxSize: 0,
minChunks: 1,
maxAsyncRequests: 5,
maxInitialRequests: 3,
automaticNameDelimiter: '~',
name: true,
cacheGroups: {
ant: {
chunks: "initial",
test: /ant\-design\-vue/,
name: 'bundle_ant',
priority: 2,
minSize: 30000,
minChunks: 1,
enforce: true,
reuseExistingChunk: true // 可设置是否重用该chunk
},
}
}
}
})