forked from PatrickJS/PatrickJS-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
161 lines (143 loc) · 3.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
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
var webpack = require('webpack');
var HtmlWebpackPlugin = require("html-webpack-plugin");
var path = require('path');
var sliceArgs = Function.prototype.call.bind(Array.prototype.slice);
var path = require('path');
module.exports = {
// devtool: 'source-maps',
devtool: 'eval',
devServer: {
inline: true,
colors: true,
historyApiFallback: true,
contentBase: 'public',
publicPath: '/__build__'
},
debug: true,
cache: true,
context: __dirname,
entry: {
angular2: [
// Angular 2 Deps
'zone.js',
// 'zone.js/dist/long-stack-trace-zone.js',
'reflect-metadata',
'rtts_assert/rtts_assert',
'./src/common/BrowserDomAdapter',
'angular2/angular2',
'angular2/router',
'angular2/di',
'angular2/src/facade/browser'
],
app: [
// App
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/dev-server',
'./src/app/bootstrap'
]
},
output: {
path: path.join(__dirname, 'public', '__build__'),
filename: '[name].js',
// filename: '[name].[hash].js',
sourceMapFilename: '[name].js.map',
chunkFilename: '[id].chunk.js'
// publicPath: 'http://mycdn.com/'
},
stats: {
colors: true,
reasons: true
},
resolve: {
root: __dirname,
extensions: [
'',
'.js',
'.ts',
// '.es6',
'.json',
'.webpack.js',
'.web.js'
],
// Todo: learn more about alias
alias: {
// When Angular2 has a TypeScript build
// 'angular2': grootNode('angular2/es6/prod'),
// 'app/*': '/app/*'
// 'components$': '/src/app/components/'
// 'decorators/*': '/app/decorators/*.js',
// 'services/*': '/app/services/*.js',
// 'stores/*': '/app/stores/*.js'
// 'angular2': 'angular2/es6/dev'
},
modulesDirectories: [
'web_modules',
'node_modules',
'src/app' // hard coded for now until I figure out alias
]
},
module: {
loaders: [
// Support for *.json files.
{ test: /\.json$/, loader: 'json' },
// Support for CSS
{ test: /\.css$/, loader: 'raw' },
// Copy all assets in to asset folder (use hash filename)
{ test: /\.(png|jpg|gif|woff|eot|ttf|svg)$/, loader: 'file?name=assets/[hash].[ext]' },
// Copy all .html as static file (keep filename)
// { test: /index[a-z-]*\.html$/, loader: 'file?name=[path][ ].html&context=./src' },
// support for .html as static file
{ test: /\.html$/, loader: 'raw' },
// Support for .ts files.
{ test: /\.ts$/, loader: 'typescript-simple' }
],
noParse: [
/rtts_assert\/src\/rtts_assert/
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'angular2',
minChunks: Infinity,
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'common',
filename: 'common.js'
}),
new webpack.DefinePlugin({
'ENV': {
'type': JSON.stringify('development'),
'debug': true
}
}),
// new HtmlWebpackPlugin({
// inject: true,
// template: './src/index.html',
// title: getBanner(),
// filename: '../index.html',
// chunks: ['shared']
// }),
// new webpack.optimize.UglifyJsPlugin({
// compress: {
// warnings: false,
// drop_debugger: false
// }
// beautify: false
// }),
new webpack.HotModuleReplacementPlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.BannerPlugin(getBanner())
]
};
function getBanner() {
return 'Angular2 Webpack Starter by @gdi2990 from @AngularClass';
}
function groot(args) {
args = sliceArgs(arguments, 0);
return path.join.apply(path, [__dirname].concat(args));
}
function grootNode(args) {
args = sliceArgs(arguments, 0);
return groot.apply(path, ['node_modules'].concat(args));
}