-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.common.js
85 lines (85 loc) · 2.17 KB
/
webpack.config.common.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
const webpack = require("webpack");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
const entry = {
index: "./src/page/index/js/index.js",
rule: "./src/page/rule/js/rule.js",
goldegg: "./src/page/goldegg/js/goldegg.js",
rank: "./src/page/rank/js/rank.js",
cash: "./src/page/cash/js/cash.js",
main: "./src/page/main/js/main.js",
};
const pages = [
// 用户中心页面
new HtmlWebpackPlugin({
title: "GoldEgg",
template: "./src/page/index/index.html",
chunks: ["commons", "index", "styles"],
filename: "index.html",
favicon: ''
}),
// 规则
new HtmlWebpackPlugin({
title: "Rule",
template: "./src/page/rule/rule.html",
chunks: ["commons", "rule", "styles"],
filename: "rule.html",
favicon: ''
}),
// 游戏主界面
new HtmlWebpackPlugin({
title: "GoldEgg",
template: "./src/page/goldegg/goldegg.html",
// inject: "head",
chunks: ["commons", "goldegg", "styles"],
filename: "goldegg.html",
favicon: ''
}),
// rank
new HtmlWebpackPlugin({
title: "Ranking",
template: "./src/page/rank/rank.html",
// inject: "head",
chunks: ["commons", "rank", "styles"],
filename: "rank.html",
favicon: ''
}),
// 提现
new HtmlWebpackPlugin({
title: "Cash",
template: "./src/page/cash/cash.html",
// inject: "head",
chunks: ["commons", "cash", "styles"],
filename: "cash.html",
favicon: ''
}),
new HtmlWebpackPlugin({
title: "GoldEggs",
template: "./src/page/main/main.html",
// inject: "head",
chunks: ["commons", "main", "styles"],
filename: "main.html",
favicon: ''
})
]
pages.forEach(item => {
item.options.minify = {
collapseWhitespace: true, // 折叠空白区域 也就是压缩代码
removeAttributeQuotes: true
}
})
module.exports = {
entry: entry,
output: {
filename: "js/[name].[hash:6].js",
path: path.resolve(__dirname, "dist"),
publicPath: ''
},
resolve: {
modules: ["node_modules", path.resolve(__dirname, "src/common"),]
},
plugins: [
new CleanWebpackPlugin(["./dist"]),
].concat(pages),
}