-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.config.js
205 lines (175 loc) · 5.24 KB
/
webpack.config.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
// var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
// module.exports = {
// entry:
// {
// main:process.cwd()+'/example1/main.js',
// },
// output: {
// path:process.cwd()+'/dest/example1',
// filename: '[name].js'
// },
// devtool:'cheap-source-map',
// plugins: [
// new CommonsChunkPlugin({
// name:"chunk",
// minChunks:2
// })
// ]
// };
// var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
// module.exports = {
// entry:
// {
// main:process.cwd()+'/example2/main.js',
// main1:process.cwd()+'/example2/main1.js',
// },
// output: {
// path:process.cwd()+'/dest/example2',
// filename: '[name].js'
// },
// plugins: [
// new CommonsChunkPlugin({
// name:"chunk",
// minChunks:2
// })
// ]
// };
// var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
// module.exports = {
// entry: {
// main: process.cwd()+'/example3/main.js',
// main1: process.cwd()+'/example3/main1.js',
// common1:["jquery"],
// common2:["vue"]
// },
// output: {
// path: process.cwd()+'/dest/example3',
// filename: '[name].js'
// },
// plugins: [
// new CommonsChunkPlugin({
// name: ["chunk",'common1','common2'],
// minChunks:2
// })
// ]
// };
// var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
// module.exports = {
// entry: {
// main: process.cwd()+'/example4/main.js',
// main1: process.cwd()+'/example4/main1.js',
// jquery:["jquery"],
// vue:["vue"]
// },
// output: {
// path: process.cwd() + '/dest/example4',
// filename: '[name].js'
// },
// plugins: [
// new CommonsChunkPlugin({
// name: ["common","jquery","vue","load"],
// minChunks:2
// })
// ]
// };
//example6
// var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
// module.exports = {
// entry: {
// main: process.cwd()+'/example5/main.js',
// main1: process.cwd()+'/example5/main1.js',
// jquery:["jquery"]
// },
// output: {
// path: process.cwd() + '/dest/example5',
// filename: '[name].js'
// },
// plugins: [
// new CommonsChunkPlugin({
// name: "jquery",
// // minChunks:2
// minChunks:Infinity
// })
// ]
// };
// var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
// module.exports = {
// entry: {
// main: process.cwd()+'/example6/main.js',
// main1: process.cwd()+'/example6/main1.js',
// jquery:["jquery"]
// },
// output: {
// path: process.cwd() + '/dest/example6',
// filename: '[name].js'
// },
// plugins: [
// new CommonsChunkPlugin({
// name: "jquery",
// minChunks:2,
// chunks:["main","main1"]
// })
// ]
// };
//library和libraryTarget与externals使用配置,见相应的文件夹或阅读[https://github.com/zhengweikeng/blog/issues/10]
// module.exports = {
// entry: { myTools: process.cwd()+"/library_libraryTarget_externals_usage/tool.js" },
// output: {
// path:process.cwd() + '/dest/library_libaryTarget_externals_usage',
// filename: '[name].js',
// chunkFilename: "[name].min.js",//chunkFilename只有在使用require.ensure时候有用(http://www.cnblogs.com/toward-the-sun/p/6147324.html?utm_source=itdadao&utm_medium=referral)
// libraryTarget: "var",
// library: "tool"
// }
// }
// var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
// var ManifestPlugin = require('webpack-manifest-plugin');
// module.exports = {
// entry: {
// main: process.cwd()+'/example8/main.js',
// main1: process.cwd()+'/example8/main1.js'
// },
// output: {
// path: process.cwd() + '/dest/example8',
// filename: '[name].js'
// },
// plugins: [
// new ManifestPlugin(),
// new CommonsChunkPlugin({
// name: "common",
// minChunks:2,
// chunks:["main","main1"]
// })
// ]
// };
//chunk-module-assets例子
var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
var FileListPlugin = require('./chunk-module-assets/FileListPlugin');
var ManifestPlugin = require('webpack-manifest-plugin');
module.exports = {
entry: {
main: process.cwd()+'/chunk-module-assets/main.js',
main1: process.cwd()+'/chunk-module-assets/main1.js',
},
output: {
path: process.cwd() + '/dest/chunk-module-assets',
filename: '[name].js'
},
module:{
rules:[
{
test: /\.(png|jpg|jpeg|gif)(\?v=\d+\.\d+\.\d+)?$/i,
use: {
loader: require.resolve("url-loader"),
//If the file is greater than the limit (in bytes) the file-loader is used and all query parameters are passed to it.
//smaller than 10kb will use dataURL
options: {
limit: 10000
}
}
}]
},
plugins: [
new FileListPlugin()
]
};