Skip to content

Commit f3d755a

Browse files
author
Oskar Karlsson
committedFeb 6, 2017
⬆️ Upgrade webpack
1 parent b9b955f commit f3d755a

File tree

5 files changed

+531
-195
lines changed

5 files changed

+531
-195
lines changed
 

‎example/boot.ts

+3-11
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,8 @@ function main() {
77
platformBrowserDynamic().bootstrapModule(AppModule);
88
}
99

10-
if (ENV === 'development' && HMR === true) {
11-
// activate hot module reload
12-
if (document.readyState === 'complete') {
13-
console.clear();
14-
main();
15-
} else {
16-
document.addEventListener('DOMContentLoaded', main);
17-
}
18-
module.hot.accept();
19-
} else {
10+
if (ENV !== 'development') {
2011
enableProdMode();
21-
main();
2212
}
13+
14+
document.addEventListener('DOMContentLoaded', main);

‎package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"prepublish": "npm run build",
88
"test": "karma start karma.local.js",
99
"test:ci": "karma start karma.ci.js",
10-
"start": "webpack-dev-server --inline --progress --profile --colors --watch --display-error-details --display-cached --hot",
10+
"start": "webpack-dev-server --progress --profile --colors --watch",
1111
"build": "copyfiles -u 1 dist/package.json .backup && rimraf dist && tsc && ngc src && copyfiles LICENSE README.md dist && copyfiles -u 1 .backup/package.json dist && rimraf dist/example dist/test .backup",
12-
"build:example": "rimraf example-dist && webpack --config webpack.prod.config.js --profile --display-error-details --display-cache && rimraf example-dist/example example-dist/src && copyfiles -u 1 example/style.css example/index.html example-dist",
12+
"build:example": "rimraf example-dist && webpack --config webpack.prod.config.js --profile && rimraf example-dist/example example-dist/src && copyfiles -u 1 example/style.css example/index.html example-dist",
1313
"e2e": "protractor",
1414
"e2e:ci": "protractor protractor.ci.conf.js",
1515
"webdriver:update": "webdriver-manager update",
@@ -48,7 +48,7 @@
4848
"@types/core-js": "^0.9.32",
4949
"@types/mocha": "^2.2.39",
5050
"@types/node": "^7.0.5",
51-
"awesome-typescript-loader": "^2.2.4",
51+
"awesome-typescript-loader": "^3.0.3",
5252
"copyfiles": "^1.2.0",
5353
"core-js": "^2.4.1",
5454
"electron-prebuilt": "^1.4.13",
@@ -68,8 +68,8 @@
6868
"source-map-loader": "^0.1.6",
6969
"typescript": "2.0.10",
7070
"wallaby-webpack": "^0.0.32",
71-
"webpack": "^1.13.3",
72-
"webpack-dev-server": "^1.16.2",
71+
"webpack": "^2.2.1",
72+
"webpack-dev-server": "^2.3.0",
7373
"zone.js": "^0.7.6"
7474
},
7575
"greenkeeper": {

‎webpack.config.js

+5-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
const path = require('path');
22
const webpack = require('webpack');
3-
const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;
43

54
const ENV = process.env.ENV = process.env.NODE_ENV = 'development';
6-
const HMR = true;
75

86
module.exports = {
97
devtool: 'inline-source-map',
108
cache: true,
11-
debug: false,
129

1310
entry: {
1411
'polyfills': './example/polyfills.ts',
@@ -17,18 +14,18 @@ module.exports = {
1714
},
1815

1916
resolve: {
20-
extensions: ['', '.ts', '.js']
17+
extensions: ['.ts', '.js']
2118
},
2219

2320
output: {
24-
path: './example',
21+
path: path.resolve(__dirname, './example'),
2522
filename: '[name].bundle.js',
2623
sourceMapFilename: '[name].js.map',
2724
chunkFilename: '[id].chunk.js'
2825
},
2926

3027
module: {
31-
preLoaders: [
28+
rules: [
3229
{
3330
test: /\.js$/,
3431
loader: 'source-map-loader',
@@ -37,9 +34,7 @@ module.exports = {
3734
path.resolve(__dirname, 'node_modules/rxjs'),
3835
path.resolve(__dirname, 'node_modules/@angular')
3936
]
40-
}
41-
],
42-
loaders: [
37+
},
4338
{ test: /\.ts$/, loader: 'awesome-typescript-loader' },
4439

4540
// Support for CSS as raw text
@@ -49,7 +44,7 @@ module.exports = {
4944

5045
// support for .html as raw text
5146
{ test: /\.html$/, loader: 'raw-loader', exclude: [ './src/index.html' ] }
52-
]
47+
],
5348
},
5449

5550
devServer: {
@@ -64,9 +59,7 @@ module.exports = {
6459
},
6560

6661
plugins: [
67-
new ForkCheckerPlugin(),
6862
new webpack.DefinePlugin({
69-
HMR,
7063
ENV: JSON.stringify(ENV)
7164
}),
7265
new webpack.optimize.CommonsChunkPlugin({

‎webpack.prod.config.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
11
const path = require('path');
22
const webpack = require('webpack');
3-
const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin;
43
const devWebpackConfig = require('./webpack.config');
54

65
const ENV = process.env.ENV = process.env.NODE_ENV = 'production';
7-
const HMR = false;
86

97
module.exports = Object.assign({}, devWebpackConfig, {
108
devtool: 'source-map',
11-
debug: false,
129
cache: false,
1310

1411
devServer: undefined,
1512
output: {
16-
path: './example-dist',
13+
path: path.resolve(__dirname, './example-dist'),
1714
filename: '[name].bundle.js',
1815
sourceMapFilename: '[name].js.map',
1916
chunkFilename: '[id].chunk.js'
2017
},
2118

2219
plugins: [
23-
new ForkCheckerPlugin(),
24-
new webpack.optimize.OccurenceOrderPlugin(true),
20+
new webpack.optimize.OccurrenceOrderPlugin(true),
2521
new webpack.optimize.DedupePlugin(),
2622
new webpack.optimize.UglifyJsPlugin({
2723
beautify: false,
@@ -36,7 +32,6 @@ module.exports = Object.assign({}, devWebpackConfig, {
3632
}),
3733
new webpack.optimize.CommonsChunkPlugin({ name: ['main', 'vendor', 'polyfills'], minChunks: Infinity }),
3834
new webpack.DefinePlugin({
39-
HMR,
4035
ENV: JSON.stringify(ENV)
4136
})
4237
]

‎yarn.lock

+516-160
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.