forked from springboot-angular2-tutorial/angular2-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
157 lines (144 loc) · 3.37 KB
/
webpack.config.js
File metadata and controls
157 lines (144 loc) · 3.37 KB
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
// Helper
var sliceArgs = Function.prototype.call.bind(Array.prototype.slice);
var NODE_ENV = process.env.NODE_ENV || 'development';
// Node
var webpack = require('webpack');
var path = require('path');
var pkg = require('./package.json');
// 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 plugins = [
new DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(NODE_ENV),
'VERSION': JSON.stringify(pkg.version)
}),
new OccurenceOrderPlugin(),
new DedupePlugin(),
new CommonsChunkPlugin({
name: 'angular2',
minChunks: Infinity,
filename: 'angular2.js'
}),
new CommonsChunkPlugin({
name: 'common',
filename: 'common.js'
})
];
if (NODE_ENV === 'production') {
plugins.push(new UglifyJsPlugin({
compress: {
warnings: false,
drop_debugger: false
},
output: {
comments: false
},
beautify: false
})
)
}
module.exports = {
devtool: 'source-map',
debug: true,
cache: true,
verbose: true,
displayErrorDetails: true,
context: __dirname,
stats: {
colors: true,
reasons: true
},
// our Development Server configs
devServer: {
inline: true,
colors: true,
historyApiFallback: true,
publicPath: '/__build__'
},
//
entry: {
'angular2': [
// Angular 2 Deps
'@reactivex/rxjs',
'zone.js',
'reflect-metadata',
// to ensure these modules are grouped together in one file
'angular2/angular2',
'angular2/router',
'angular2/http',
'angular2/core'
],
'app': [
'./src/app/bootstrap'
]
},
// Config for our build files
output: {
path: root('__build__'),
filename: '[name].js',
// filename: '[name].[hash].js',
sourceMapFilename: '[name].js.map',
chunkFilename: '[id].chunk.js'
},
resolve: {
root: __dirname,
extensions: ['', '.js', '.ts', '.json'],
alias: {
'app': 'src/app'
}
},
/*
* When using `templateUrl` and `styleUrls` please use `__filename`
* rather than `module.id` for `moduleId` in `@View`
*/
node: {
crypto: false,
__filename: true
},
module: {
loaders: [
{test: /\.json$/, loader: 'json'},
{test: /\.css$/, loader: 'raw'},
{
test: /\.scss$/,
loaders: ["raw", "sass"]
},
{test: /\.html$/, loader: 'raw'},
{
test: /\.ts$/,
loader: 'ts',
exclude: [
/\.min\.js$/,
/\.spec\.ts$/,
/node_modules/
]
},
{
test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/font-woff'
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=application/octet-stream'
},
{test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file'},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url?limit=10000&mimetype=image/svg+xml'
}
],
noParse: [
/rtts_assert\/src\/rtts_assert/,
/reflect-metadata/
]
},
plugins: plugins
};
function root(args) {
args = sliceArgs(arguments, 0);
return path.join.apply(path, [__dirname].concat(args));
}