forked from hydecorp/hydejack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
69 lines (60 loc) · 1.51 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
const { readFileSync } = require('fs');
const { resolve } = require('path');
const rxPaths = require('rxjs/_esm5/path-mapping');
const {
BannerPlugin,
EnvironmentPlugin,
} = require('webpack');
const merge = require('webpack-merge');
const { argv: { mode } } = require('yargs');
const { name: filename, version } = require('./package.json');
const banner = readFileSync(resolve('./_includes/header.txt'), 'utf-8');
const flatten = [(a, x) => a.concat(x), []];
function envConfig() {
switch (mode) {
case 'production':
return {
plugins: [
new BannerPlugin({ banner, raw: true }),
new EnvironmentPlugin({ DEBUG: false }),
],
};
default:
return {
devtool: 'source-map',
plugins: [new EnvironmentPlugin({ DEBUG: true })],
};
}
}
module.exports = merge(
{
entry: resolve('./_js/src/index.js'),
output: {
path: resolve('./assets/js'),
filename: `${filename}-${version}.js`,
},
module: {
rules: [
{
test: /(\.jsx|\.js)$/,
loader: 'babel-loader',
options: {
presets: [['env', { modules: false }]],
babelrc: false,
},
},
],
},
resolve: {
modules: [
resolve('./_js'),
resolve('./node_modules'),
process.env.NODE_PATH ? resolve(process.env.NODE_PATH) : [],
].reduce(...flatten),
extensions: ['.json', '.js'],
symlinks: true,
alias: rxPaths(),
},
},
envConfig()
);