This repository has been archived by the owner on Feb 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
/
webpack.config.js
194 lines (166 loc) · 4.48 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
// @AngularClass
/*
* Helper
* env(), getBanner(), root(), and rootDir()
* are defined at the bottom
*/
var sliceArgs = Function.prototype.call.bind(Array.prototype.slice);
var toString = Function.prototype.call.bind(Object.prototype.toString);
var NODE_ENV = process.env.NODE_ENV || 'development';
var pkg = require('./package.json');
// Polyfill
Object.assign = require('object-assign');
// Node
var path = require('path');
// NPM
var webpack = require('webpack');
// Webpack Plugins
var OccurenceOrderPlugin = webpack.optimize.OccurenceOrderPlugin;
var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
var UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
var DedupePlugin = webpack.optimize.DedupePlugin;
var DefinePlugin = webpack.DefinePlugin;
var BannerPlugin = webpack.BannerPlugin;
/*
* Config
*/
module.exports = {
devtool: 'source-map',
debug: true,
cache: true,
verbose: true,
displayErrorDetails: true,
context: root(),
stats: {
colors: true,
reasons: true
},
// our Development Server config
devServer: {
inline: true,
colors: true,
historyApiFallback: true,
contentBase: 'src/public',
publicPath: '/__build__'
},
//
entry: {
'bootstrap-client': [
// Angular 2 Deps
'zone.js',
'@reactivex/rxjs',
'reflect-metadata',
// to ensure these modules are grouped together in one file
'angular2/angular2',
'angular2/core',
'angular2/router',
'angular2/http',
'./src/app/bootstrap-client'
],
'bootstrap-ui': [
'zone.js',
'@reactivex/rxjs',
'reflect-metadata',
'angular2/web_worker/ui',
'./src/app/bootstrap-ui'
],
'bootstrap-worker': [
'zone.js',
'@reactivex/rxjs',
'reflect-metadata',
'angular2/web_worker/worker',
'angular2/angular2',
'angular2/router',
'angular2/http',
'./src/app/bootstrap-worker'
]
},
// Config for our build files
output: {
path: root('__build__'),
filename: '[name].js',
sourceMapFilename: '[name].js.map',
chunkFilename: '[id].chunk.js'
// publicPath: 'http://mycdn.com/'
},
resolve: {
root: root(),
extensions: ['','.ts','.js','.json'],
alias: {
'rx': '@reactivex/rxjs'
// 'common': 'src/common',
// 'bindings': 'src/bindings',
// 'components': 'src/app/components'
// 'services': 'src/app/services',
// 'stores': 'src/app/stores'
}
},
module: {
loaders: [
// Support for *.json files.
{ test: /\.json$/, loader: 'json' },
// Support for CSS as raw text
{ test: /\.css$/, loader: 'raw' },
// support for .html as raw text
{ test: /\.html$/, loader: 'raw' },
// Support for .ts files.
{ test: /\.ts$/, loader: 'ts',
query: {
'ignoreDiagnostics': [
// 2300, // 2300 -> Duplicate identifier
// 2309 // 2309 -> An export assignment cannot be used in a module with other exported elements.
]
},
exclude: [
/\.min\.js$/,
/\.spec\.ts$/,
/\.e2e\.ts$/,
/web_modules/,
/test/,
/node_modules/
]
}
],
noParse: [
/rtts_assert\/src\/rtts_assert/,
/reflect-metadata/
]
},
plugins: [
// new DefinePlugin({
// 'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
// 'VERSION': JSON.stringify(pkg.version)
// }),
// new OccurenceOrderPlugin(),
// new DedupePlugin()
],
/*
* When using `templateUrl` and `styleUrls` please use `__filename`
* rather than `module.id` for `moduleId` in `@View`
*/
node: {
crypto: false,
__filename: true
}
};
// Helper functions
function env(configEnv) {
if (configEnv === undefined) { return configEnv; }
switch (toString(configEnv[NODE_ENV])) {
case '[object Object]' : return Object.assign({}, configEnv.all || {}, configEnv[NODE_ENV]);
case '[object Array]' : return [].concat(configEnv.all || [], configEnv[NODE_ENV]);
case '[object Undefined]' : return configEnv.all;
default : return configEnv[NODE_ENV];
}
}
function getBanner() {
return 'Angular2 Webpack Starter v'+ pkg.version +' by @gdi2990 from @AngularClass';
}
function root(args) {
args = sliceArgs(arguments, 0);
return path.join.apply(path, [__dirname].concat(args));
}
function rootNode(args) {
args = sliceArgs(arguments, 0);
return root.apply(path, ['node_modules'].concat(args));
}