-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
53 lines (50 loc) · 1.1 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
const path = require('path');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
const PROD = 1, DEV = 2;
function getTarget(env) {
if (!env.target) {
console.error('ERROR: no "target" environment found!');
console.error(' use --env.target=PROD|DEV in webpack command line');
process.exit(2);
}
console.log('Building for target: ' + env.target);
switch (env.target) {
case 'PROD': return PROD;
case 'DEV': return DEV;
default:
console.error(`ERROR: invalid target "${env.target}"`);
process.exit(1);
}
}
module.exports = function(env) {
let target = getTarget(env);
let plugins = [];
if (target == PROD) {
plugins = [
new UglifyJSPlugin()
];
}
return {
devtool: 'source-map',
entry: {
'tsp-cli': ['./src/tsp-cli.ts'],
'tsp-web': ['./src/tsp-web.ts'],
'tsp-worker': ['./src/tsp-worker.ts']
},
resolve: {
extensions: ['.webpack.js', '.ts', '.js']
},
module: {
loaders: [{
test: /\.ts$/,
loader: 'ts-loader',
exclude: '/node_modules'
}]
},
plugins,
output: {
path: path.resolve(__dirname, 'web'),
filename: '[name].js'
}
};
}