-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
51 lines (48 loc) · 1.17 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
'use strict';
const path = require('path');
const webpack = require('webpack');
let common_config = {
entry: ['./src/main'],
output: {
filename: 'js/bundle.js',
path: path.join(__dirname, 'bin'),
},
resolve: {
extensions: ['.ts', '.js', '.json'],
},
module: {
rules: [
{
test: /\.(.*)?$/,
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
],
},
};
const dev_config = {
devtool: 'eval-source-map',
watch: true,
devServer: {
host: '0.0.0.0',
contentBase: path.join(__dirname, 'bin'),
},
};
const prod_config = {
entry: ['es6-promise', './src/main.ts'],
};
const prod_ts_compile_option = {
target: 'es5',
sourceMap: false,
lib: ['dom', 'es5', 'es2015.promise'],
};
module.exports = (env, argv) => {
if (argv.mode === 'development') {
return Object.assign(common_config, dev_config);
} else {
common_config.module.rules[0].options.compilerOptions = prod_ts_compile_option;
return Object.assign(common_config, prod_config);
}
};