-
Notifications
You must be signed in to change notification settings - Fork 3
/
.webpackrc.js
87 lines (86 loc) · 2.2 KB
/
.webpackrc.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
import path from "path";
export default {
extraResolveExtensions: ["ts", "tsx", "js", "jsx"],
alias: {
"@": path.resolve(__dirname, "./src/")
},
proxy: {
"/api": {
target: "http://baidu.com",
changeOrigin: true,
secure: false
}
},
extraBabelPlugins: [
[
"import",
{
libraryName: "自己的组件",
style: true
}
]
],
entry: {
index: "./src/index.js",
vendor: [
"moment",
"mockjs",
"axios",
"babel-polyfill",
"react",
"react-dom"
]
},
env: {
development: {
extraBabelPlugins: ["dva-hmr"],
publicPath: "/"
},
production: {
publicPath: "/"
}
},
outputPath: "dist",
hash: true,
commons: [
{
names: ["vendor", "index"],
minChunks: Infinity,
chunks: ["index"]
},
{
name: "common",
minChunks: function(module) {
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf(
path.join(__dirname, "./node_modules")
) === 0
);
},
chunks: ["index"]
}
],
html: {
template: "public/index.ejs",
title: "myProduct",
inject: true,
hash: true,
chunksSortMode: "manual",
chunks: ["vendor", "common", "index"],
minify:
process.env.NODE_ENV === "development"
? false
: {
// 是否对大小写敏感,默认false
caseSensitive: false,
// 是否移除注释 默认false
removeComments: true,
// 是否删除空属性,默认false
removeEmptyAttributes: false,
// 是否去除空格,默认false
collapseWhitespace: false
}
}
};