-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.prod.js
executable file
·87 lines (81 loc) · 2.08 KB
/
webpack.config.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
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
76
77
78
79
80
81
82
83
84
85
86
87
/**
* webpack config development
* @auther:[email protected]
* @update:2019-5-12
*/
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require(`html-webpack-plugin`);
const miniCSSExtractPlugin = require('mini-css-extract-plugin');
const webpackProdConfig = {
mode: 'production',
target: 'web',
entry: {
home: ['./src/page/home/index.js'],
},
// optimization: {
// splitChunks: {
// cacheGroups: {
// // 注意: priority属性
// // 其次: 打包业务中公共代码
// common: {
// name: 'common',
// chunks: 'all',
// minSize: 1,
// priority: 0,
// },
// // 首先: 打包node_modules中的文件
// vendor: {
// name: 'vendor',
// test: /[\\/]node_modules[\\/]/,
// chunks: 'all',
// priority: 10,
// },
// },
// },
// },
module: {
rules: [
{
test: /\.(less|css)$/,
use: [
{
loader: 'style-loader',
},
{
loader: miniCSSExtractPlugin.loader,
},
{
loader: 'css-loader',
},
{
loader: 'postcss-loader',
},
{ loader: 'less-loader' },
],
},
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/, // 要排除node_modules,bower_components下的JS文件
loader: 'babel-loader',
},
],
},
plugins: [
new miniCSSExtractPlugin({
filename: './assets/css/[name].[hash].css',
chunkFilename: './assets/css/[id].[hash].css',
}),
new HtmlWebpackPlugin({
filename: 'page/home/index.html',
template: './src/page/home/index.ejs',
inject: true,
chunks: ['home'],
minify: true,
cdn: {
js: [`https://cdn.bootcss.com/vConsole/3.3.0/vconsole.min.js`],
},
}),
],
};
module.exports = webpackProdConfig;