diff --git a/public/docs/_examples/package.json b/public/docs/_examples/package.json
index b1bce74b86..583d479cb6 100644
--- a/public/docs/_examples/package.json
+++ b/public/docs/_examples/package.json
@@ -40,16 +40,16 @@
"@types/angular-sanitize": "^1.3.3",
"@types/jasmine": "~2.5.36",
"@types/node": "^6.0.45",
- "angular2-template-loader": "^0.4.0",
- "awesome-typescript-loader": "^2.2.4",
+ "angular2-template-loader": "^0.6.0",
+ "awesome-typescript-loader": "^3.0.0-beta.18",
"babel-cli": "^6.16.0",
"babel-preset-angular2": "^0.0.2",
"babel-preset-es2015": "^6.16.0",
"canonical-path": "0.0.2",
"concurrently": "^3.0.0",
- "css-loader": "^0.25.0",
- "extract-text-webpack-plugin": "^1.0.1",
- "file-loader": "^0.8.5",
+ "css-loader": "^0.26.1",
+ "extract-text-webpack-plugin": "2.0.0-beta.5",
+ "file-loader": "^0.9.0",
"html-loader": "^0.4.3",
"html-webpack-plugin": "^2.16.1",
"http-server": "^0.9.0",
@@ -62,7 +62,7 @@
"karma-jasmine-html-reporter": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.2",
"karma-sourcemap-loader": "^0.3.7",
- "karma-webpack": "^1.8.0",
+ "karma-webpack": "^2.0.1",
"lite-server": "^2.2.2",
"lodash": "^4.16.2",
"null-loader": "^0.1.1",
@@ -79,9 +79,9 @@
"ts-node": "^1.3.0",
"tslint": "^3.15.1",
"typescript": "~2.0.10",
- "webpack": "^1.13.0",
- "webpack-dev-server": "^1.14.1",
- "webpack-merge": "^0.14.0"
+ "webpack": "2.2.0",
+ "webpack-dev-server": "2.2.0-rc.0",
+ "webpack-merge": "^2.4.0"
},
"repository": {}
}
diff --git a/public/docs/_examples/webpack/ts-snippets/webpack.config.snippets.ts b/public/docs/_examples/webpack/ts-snippets/webpack.config.snippets.ts
index 3211e5e2db..a15d4ee215 100644
--- a/public/docs/_examples/webpack/ts-snippets/webpack.config.snippets.ts
+++ b/public/docs/_examples/webpack/ts-snippets/webpack.config.snippets.ts
@@ -32,14 +32,14 @@ output: {
// #enddocregion two-entries
// #docregion loaders
-loaders: [
+rules: [
{
test: /\.ts$/
- loaders: 'ts'
+ loader: 'awesome-typescript-loader'
},
{
test: /\.css$/
- loaders: 'style!css'
+ loaders: 'style-loader!css-loader'
}
]
// #enddocregion loaders
diff --git a/public/docs/_examples/webpack/ts/config/webpack.common.js b/public/docs/_examples/webpack/ts/config/webpack.common.js
index 771294130e..5f83bfdde5 100644
--- a/public/docs/_examples/webpack/ts/config/webpack.common.js
+++ b/public/docs/_examples/webpack/ts/config/webpack.common.js
@@ -15,34 +15,34 @@ module.exports = {
// #docregion resolve
resolve: {
- extensions: ['', '.ts', '.js']
+ extensions: ['.ts', '.js']
},
// #enddocregion resolve
// #docregion loaders
module: {
- loaders: [
+ rules: [
{
test: /\.ts$/,
loaders: ['awesome-typescript-loader', 'angular2-template-loader']
},
{
test: /\.html$/,
- loader: 'html'
+ loader: 'html-loader'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
- loader: 'file?name=assets/[name].[hash].[ext]'
+ loader: 'file-loader?name=assets/[name].[hash].[ext]'
},
{
test: /\.css$/,
exclude: helpers.root('src', 'app'),
- loader: ExtractTextPlugin.extract('style', 'css?sourceMap')
+ loader: ExtractTextPlugin.extract({ fallbackLoader: 'style-loader', loader: 'css-loader?sourceMap' })
},
{
test: /\.css$/,
include: helpers.root('src', 'app'),
- loader: 'raw'
+ loader: 'raw-loader'
}
]
},
@@ -50,6 +50,14 @@ module.exports = {
// #docregion plugins
plugins: [
+ // Workaround for angular/angular#11580
+ new webpack.ContextReplacementPlugin(
+ // The (\\|\/) piece accounts for path separators in *nix and Windows
+ /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
+ helpers.root('./src'), // location of your src
+ {} // a map of your routes
+ ),
+
new webpack.optimize.CommonsChunkPlugin({
name: ['app', 'vendor', 'polyfills']
}),
diff --git a/public/docs/_examples/webpack/ts/config/webpack.prod.js b/public/docs/_examples/webpack/ts/config/webpack.prod.js
index 7b2f8f9800..d6c70119bc 100644
--- a/public/docs/_examples/webpack/ts/config/webpack.prod.js
+++ b/public/docs/_examples/webpack/ts/config/webpack.prod.js
@@ -17,13 +17,8 @@ module.exports = webpackMerge(commonConfig, {
chunkFilename: '[id].[hash].chunk.js'
},
- htmlLoader: {
- minimize: false // workaround for ng2
- },
-
plugins: [
- new webpack.NoErrorsPlugin(),
- new webpack.optimize.DedupePlugin(),
+ new webpack.NoEmitOnErrorsPlugin(),
new webpack.optimize.UglifyJsPlugin({ // https://github.com/angular/angular/issues/10618
mangle: {
keep_fnames: true
@@ -34,7 +29,13 @@ module.exports = webpackMerge(commonConfig, {
'process.env': {
'ENV': JSON.stringify(ENV)
}
+ }),
+ new webpack.LoaderOptionsPlugin({
+ htmlLoader: {
+ minimize: false // workaround for ng2
+ }
})
]
});
+
// #enddocregion
diff --git a/public/docs/_examples/webpack/ts/config/webpack.test.js b/public/docs/_examples/webpack/ts/config/webpack.test.js
index c3f8727e70..f9e15d4679 100644
--- a/public/docs/_examples/webpack/ts/config/webpack.test.js
+++ b/public/docs/_examples/webpack/ts/config/webpack.test.js
@@ -1,39 +1,50 @@
// #docregion
+var webpack = require('webpack');
var helpers = require('./helpers');
module.exports = {
devtool: 'inline-source-map',
resolve: {
- extensions: ['', '.ts', '.js']
+ extensions: ['.ts', '.js']
},
module: {
- loaders: [
+ rules: [
{
test: /\.ts$/,
loaders: ['awesome-typescript-loader', 'angular2-template-loader']
},
{
test: /\.html$/,
- loader: 'html'
+ loader: 'html-loader'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
- loader: 'null'
+ loader: 'null-loader'
},
{
test: /\.css$/,
exclude: helpers.root('src', 'app'),
- loader: 'null'
+ loader: 'null-loader'
},
{
test: /\.css$/,
include: helpers.root('src', 'app'),
- loader: 'raw'
+ loader: 'raw-loader'
}
]
- }
+ },
+
+ plugins: [
+ new webpack.ContextReplacementPlugin(
+ // The (\\|\/) piece accounts for path separators in *nix and Windows
+ /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
+ helpers.root('./src'), // location of your src
+ {} // a map of your routes
+ )
+ ]
}
+
// #enddocregion
diff --git a/public/docs/_examples/webpack/ts/package.webpack.json b/public/docs/_examples/webpack/ts/package.webpack.json
index 9ff44fee78..7f51557376 100644
--- a/public/docs/_examples/webpack/ts/package.webpack.json
+++ b/public/docs/_examples/webpack/ts/package.webpack.json
@@ -24,27 +24,27 @@
"devDependencies": {
"@types/node": "^6.0.45",
"@types/jasmine": "^2.5.35",
- "angular2-template-loader": "^0.4.0",
- "awesome-typescript-loader": "^2.2.4",
- "css-loader": "^0.23.1",
- "extract-text-webpack-plugin": "^1.0.1",
- "file-loader": "^0.8.5",
+ "angular2-template-loader": "^0.6.0",
+ "awesome-typescript-loader": "^3.0.0-beta.18",
+ "css-loader": "^0.26.1",
+ "extract-text-webpack-plugin": "2.0.0-beta.5",
+ "file-loader": "^0.9.0",
"html-loader": "^0.4.3",
- "html-webpack-plugin": "^2.15.0",
+ "html-webpack-plugin": "^2.16.1",
"jasmine-core": "^2.4.1",
"karma": "^1.2.0",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.2",
"karma-sourcemap-loader": "^0.3.7",
- "karma-webpack": "^1.8.0",
+ "karma-webpack": "^2.0.1",
"null-loader": "^0.1.1",
"phantomjs-prebuilt": "^2.1.7",
"raw-loader": "^0.5.1",
"rimraf": "^2.5.2",
"style-loader": "^0.13.1",
"typescript": "~2.0.10",
- "webpack": "^1.13.0",
- "webpack-dev-server": "^1.14.1",
- "webpack-merge": "^0.14.0"
+ "webpack": "2.2.0",
+ "webpack-dev-server": "2.2.0-rc.0",
+ "webpack-merge": "^2.4.0"
}
}
diff --git a/public/docs/_examples/webpack/ts/src/polyfills.ts b/public/docs/_examples/webpack/ts/src/polyfills.ts
index bc3ccc5993..118acd2b0c 100644
--- a/public/docs/_examples/webpack/ts/src/polyfills.ts
+++ b/public/docs/_examples/webpack/ts/src/polyfills.ts
@@ -5,11 +5,8 @@ require('zone.js/dist/zone');
if (process.env.ENV === 'production') {
// Production
-
} else {
- // Development
-
+ // Development and test
Error['stackTraceLimit'] = Infinity;
-
require('zone.js/dist/long-stack-trace-zone');
}
diff --git a/public/docs/ts/latest/guide/webpack.jade b/public/docs/ts/latest/guide/webpack.jade
index a88095883f..365583e98a 100644
--- a/public/docs/ts/latest/guide/webpack.jade
+++ b/public/docs/ts/latest/guide/webpack.jade
@@ -1,12 +1,17 @@
include ../_util-fns
+// The docs standard h4 style uppercases, making code terms unreadable. Override it.
+style.
+ h4 {font-size: 17px !important; text-transform: none !important;}
+ .syntax { font-family: Consolas, 'Lucida Sans', Courier, sans-serif; color: black; font-size: 85%; }
+
:marked
[**Webpack**](https://webpack.github.io/) is a popular module bundler,
a tool for bundling application source code in convenient _chunks_
and for loading that code from a server into a browser.
- It's an excellent alternative to the *SystemJS* approach we use throughout the documentation.
- In this guide we get a taste of Webpack and how to use it with Angular applications.
+ It's an excellent alternative to the *SystemJS* approach used elsewhere in the documentation.
+ This guide offers a taste of Webpack and explains how to use it with Angular applications.
## Table of contents
@@ -40,17 +45,17 @@ include ../_util-fns
Webpack roams over your application source code,
looking for `import` statements, building a dependency graph, and emitting one (or more) _bundles_.
- With plugin "loaders" Webpack can preprocess and minify different non-JavaScript files such as TypeScript, SASS, and LESS files.
+ With plugins and rules, Webpack can preprocess and minify different non-JavaScript files such as TypeScript, SASS, and LESS files.
- We determine what Webpack does and how it does it with a JavaScript configuration file, `webpack.config.js`.
+ You determine what Webpack does and how it does it with a JavaScript configuration file, `webpack.config.js`.
a(id="entries-outputs")
.l-main-section
:marked
### Entries and outputs
- We feed Webpack with one or more *entry* files and let it find and incorporate the dependencies that radiate from those entries.
- In this example, we start from the application's root file, `src/app.ts`:
+ You supply Webpack with one or more *entry* files and let it find and incorporate the dependencies that radiate from those entries.
+ The one entry point file in this example is the application's root file, `src/app.ts`:
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'one-entry', 'webpack.config.js (single entry)')(format=".")
@@ -60,38 +65,37 @@ a(id="entries-outputs")
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'app-example', 'src/app.ts')(format=".")
:marked
- Here it sees that we're importing *@angular/core* so it adds that to its dependency list for (potential) inclusion in the bundle.
- It opens *@angular/core* and follows _its_ network of `import` statements until it has built the complete dependency graph from `app.ts` down.
+ It sees that you're importing *@angular/core* so it adds that to its dependency list for (potential) inclusion in the bundle.
+ It opens the *@angular/core* file and follows _its_ network of `import` statements until it has built the complete dependency graph from `app.ts` down.
Then it **outputs** these files to the `app.js` _bundle file_ designated in configuration:
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'one-output', 'webpack.config.js (single output)')(format=".")
:marked
- This `app.js` output bundle is a single JavaScript file that contains our application source and its dependencies.
- We'll load it later with a <script> tag in our index.html.
+ This `app.js` output bundle is a single JavaScript file that contains the application source and its dependencies.
+ You'll load it later with a `