-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
65 lines (59 loc) · 1.94 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
'use strict';
// modules /////////////////////////////////////////////////////////////////////////////////////////////////////////////
var webpack = require('webpack');
var path = require('path');
var ngAnnotatePlugin = require('ng-annotate-webpack-plugin');
// pathes //////////////////////////////////////////////////////////////////////////////////////////////////////////////
var srcPath = path.resolve(__dirname, 'src', 'app.js');
var dstPath = path.resolve(__dirname, 'web', 'js');
// vars ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var nodeEnv = process.env.NODE_ENV || 'development';
var apiUrl = process.env.apiUrl || '';
// the base config /////////////////////////////////////////////////////////////////////////////////////////////////////
var config = {
entry: srcPath,
output: {
path: dstPath,
filename: 'app.js'
},
module: {
loaders: [
{
test: /\.json$/,
loader: 'json-loader'
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
// 'NODE_ENV': JSON.stringify(nodeEnv),
'appversion': JSON.stringify(require('./package.json').version),
// 'apiUrl': JSON.stringify(apiUrl)
}
}),
new ngAnnotatePlugin({add: true}),
new webpack.optimize.UglifyJsPlugin(
{compress: {warnings: false}}
),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin()
]
};
// environment switch //////////////////////////////////////////////////////////////////////////////////////////////////
switch (nodeEnv) {
case 'development':
case 'test':
config.devtool = 'source-map';
break;
case 'staging':
config.devtool = 'cheap-module-source-map';
break;
case 'production':
config.devtool = 'cheap-module-source-map';
break;
default:
console.error('No task for environment:', nodeEnv);
process.exit(1);
}
module.exports = config;