-
Notifications
You must be signed in to change notification settings - Fork 126
/
webpack.config.js
54 lines (42 loc) · 1.12 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
// webpack.config.js
const path = require('path');
const glob = require('glob');
var addUI = require('./addUI');
// let entry = getEntry('./src/work/**.js');
function getEntry(globPath, options) {
options = options || {};
var entries = {},
basename, tmp, pathname;
glob.sync(globPath, options).forEach(function (entry) {
pathname = entry.replace(/\.js$/,'').replace(/^\.\/src\/work\//,'');
let fpath = entry;
if(options.cwd){
fpath = path.join(options.cwd, entry);
}
entries[pathname] = [fpath];
});
return entries;
}
var config = {
// entry: getEntry('./src/work/*.js'),
entry: getEntry('./src/work/微博-删除重复微博.js'),
output: {
// filename: 'main.js',
//注意:使用[name]确保每个文件名都不重复
filename: '[name].js',
// filename: '[name]-[hash].js',
path: path.resolve(__dirname, 'dist')
},
plugins: [
new addUI({ options: true })
]
};
module.exports = (env, argv) => {
if (argv.mode === 'development') {
config.devtool = 'source-map';
}
if (argv.mode === 'production') {
//...
}
return config;
};