forked from andrey-git/home-assistant-custom-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
65 lines (58 loc) · 1.43 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 UglifyJsPlugin = require('uglifyjs-webpack-plugin');
function createConfig(es5, prod) {
const buildPath = 'build';
const entry = {
scripts: './src/entrypoints/scripts.js',
};
const babelOptions = {};
babelOptions.presets =
[
es5 && [
require('@babel/preset-env').default,
{ modules: false },
],
require('@babel/preset-typescript').default,
].filter(Boolean);
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$|\.ts$/,
use: {
loader: 'babel-loader',
options: babelOptions,
},
},
],
},
plugins,
resolve: {
extensions: ['.ts', '.js', '.json'],
},
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;