-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
82 lines (76 loc) · 1.64 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
const _ = require('lodash');
const path = require('path');
const appDir = path.resolve(__dirname, 'src/app');
const destDir = path.resolve(__dirname, 'dist/app');
const common = {
module: {
rules: [
{
test: /\.js$/,
include: [
appDir
],
exclude: [],
use: {
loader: 'babel-loader'
}
},
]
},
resolve: {
modules: [
'node_modules',
appDir
],
extensions: ['.js', '.json', '.jsx'],
fallback: {
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
buffer: require.resolve('buffer')
}
},
watchOptions: {
aggregateTimeout: 2000,
poll: 1000,
ignored: [
/src\/(?!app)\/*/, // only rebuild changes to src/app
'node_modules/**',
].join(',') // Convert the array to a comma-separated string
},
devtool: 'source-map',
context: __dirname
};
const errorjs = {
name: 'errorjs',
entry: './src/app/error.js',
output: {
path: destDir,
filename: 'error.js',
sourceMapFilename: '[file].map', // string
libraryTarget: 'umd'
},
target: 'web'
};
const mainjs = {
name: 'mainjs',
entry: './src/app/main.js',
output: {
path: destDir,
filename: 'main.js',
sourceMapFilename: '[file].map', // string
libraryTarget: 'umd'
},
target: 'web',
optimization: {
minimize: false
}
};
_.merge(errorjs, common);
_.merge(mainjs, common);
module.exports = (env, argv) => {
if (!argv.mode)
argv.mode = process.env.NODE_ENV || 'development';
mainjs.mode = argv.mode;
errorjs.mode = argv.mode;
return [mainjs, errorjs];
};