forked from andrey-git/home-assistant-custom-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
68 lines (61 loc) · 1.4 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
const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
function createConfig(es5, prod) {
const buildPath = 'build';
const entry = {
scripts: './src/entrypoints/scripts.js',
};
const babelOptions = {};
babelOptions.presets =
es5 ? [
['es2015', { modules: false }],
] : [
['env', {
targets: {
chrome: 55,
firefox: 47,
edge: 14,
safari: 10,
},
modules: false,
}],
];
const plugins = prod ?
[new UglifyJsPlugin({
extractComments: true,
sourceMap: true,
uglifyOptions: {
// Disabling because it broke output
mangle: false,
},
}),
] : [];
return {
mode: prod ? 'production' : 'development',
devtool: prod ? 'source-map ' : 'inline-source-map',
entry,
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: babelOptions,
},
},
],
},
plugins,
output: {
filename: `[name]${prod ? '' : '-dbg'}${es5 ? '-es5' : ''}.js`,
path: path.resolve(__dirname, buildPath),
},
};
}
const configs = [
createConfig(/* es5= */true, /* prod= */true),
createConfig(/* es5= */false, /* prod= */true),
createConfig(/* es5= */true, /* prod= */false),
createConfig(/* es5= */false, /* prod= */false),
];
module.exports = configs;