-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
webpack.config.js
66 lines (57 loc) · 1.47 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
const webpack = require('webpack');
const glob = require('glob');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
let globOptions = {
ignore: ['node_modules/**', 'venv/**']
}
let entryFiles = glob.sync("**/javascript/*.js", globOptions)
let entryObj = {};
entryFiles.forEach(function(file){
if (file.includes('.')) {
let parts = file.split('/')
let path = parts.pop()
let fileName = path.split('.')[0];
entryObj[fileName] = `./${file}`;
}
});
let sockpuppet = {sockpuppet: "./sockpuppet/js/sockpuppet.js"}
let sourceMap = new webpack.SourceMapDevToolPlugin({
publicPath: '/static/sockpuppet/',
filename: '[name].js.map'
});
const isProd = process.env.NODE_ENV === 'production'
module.exports = [
function(env, argv) {
let config = {
mode: process.env.NODE_ENV,
entry: entryObj,
output: {
path: __dirname + '/jsdist/js',
filename: '[name].js'
},
optimization: {
minimize: isProd
},
plugins: []
}
// if (env.analyze) {
// config.plugins.push(new BundleAnalyzerPlugin())
// }
return config
},
function(env, argv) {
let config = {
mode: process.env.NODE_ENV,
entry: sockpuppet,
output: {
path: __dirname + '/sockpuppet/static/sockpuppet',
filename: '[name].js'
},
optimization: {
minimize: isProd
},
plugins: [sourceMap]
}
return config
}
]