-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.config.js
65 lines (56 loc) · 1.59 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
const path = require('path');
const loadEnv = require('./loadEnv');
const entry = require('./webpack/config.entry');
const rules = require('./webpack/config.rules');
const plugins = require('./webpack/config.plugins.js');
const stats = require('./webpack/config.stats');
const { getBuildPath } = require('./webpack/packageNaming');
// const {} = packageNaming;
loadEnv({ path: path.resolve(__dirname) });
module.exports = function webpack(env = {}, argv = {}) {
env = {
PLATFORM: 'chromium',
FACET: 'dismoi',
...process.env,
...env
};
console.log(env.FACET, env.NODE_ENV, env.PLATFORM);
const srcPath = path.resolve(__dirname, 'src');
const { NODE_ENV, PLATFORM, FACET } = env;
const buildPath = path.resolve(
__dirname,
getBuildPath(PLATFORM, NODE_ENV, FACET)
);
console.info('Building package to: ', buildPath);
return {
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
modules: [srcPath, 'node_modules'],
alias: {
test: path.resolve(__dirname, 'test')
}
},
entry: entry(env, srcPath),
output: {
filename: 'js/[name].bundle.js',
chunkFilename: 'js/[id].chunk.js',
path: buildPath,
publicPath: ''
},
module: { rules: rules(env, argv) },
plugins: plugins(env, argv, buildPath),
optimization: { minimize: false },
node: {
module: 'empty',
dgram: 'empty',
dns: 'mock',
fs: 'empty',
http2: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
},
devtool: argv.watch ? 'eval-source-map' : 'source-map',
stats
};
};