Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit ea63848

Browse files
Foxandxsswardbell
authored andcommitted
docs(webpack): remove ts-snippets (#3398)
1 parent de65111 commit ea63848

File tree

4 files changed

+59
-73
lines changed

4 files changed

+59
-73
lines changed

public/docs/_examples/webpack/ts-snippets/webpack.config.snippets.ts

Lines changed: 0 additions & 58 deletions
This file was deleted.

public/docs/_examples/webpack/ts/config/webpack.common.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
// #docplaster
12
// #docregion
23
var webpack = require('webpack');
34
var HtmlWebpackPlugin = require('html-webpack-plugin');
45
var ExtractTextPlugin = require('extract-text-webpack-plugin');
56
var helpers = require('./helpers');
67

78
module.exports = {
8-
// #docregion entries
9+
// #docregion entries, one-entry, two-entries
910
entry: {
11+
// #enddocregion one-entry, two-entries
1012
'polyfills': './src/polyfills.ts',
13+
// #docregion two-entries
1114
'vendor': './src/vendor.ts',
15+
// #docregion one-entry
1216
'app': './src/main.ts'
1317
},
14-
// #enddocregion
18+
// #enddocregion entries, one-entry, two-entries
1519

1620
// #docregion resolve
1721
resolve: {

public/docs/_examples/webpack/ts/src/app/app.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
// #docplaster
12
// #docregion
3+
// #docregion component
24
import { Component } from '@angular/core';
35

6+
// #enddocregion component
47
import '../assets/css/styles.css';
58

9+
// #docregion component
610
@Component({
711
selector: 'my-app',
812
templateUrl: './app.component.html',

public/docs/ts/latest/guide/webpack.jade

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,26 @@ a(id="entries-outputs")
5757
### Entries and outputs
5858

5959
You supply Webpack with one or more *entry* files and let it find and incorporate the dependencies that radiate from those entries.
60-
The one entry point file in this example is the application's root file, `src/app.ts`:
60+
The one entry point file in this example is the application's root file, `src/main.ts`:
6161

62-
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'one-entry', 'webpack.config.js (single entry)')(format=".")
62+
+makeExample('webpack/ts/config/webpack.common.js', 'one-entry', 'webpack.config.js (single entry)')(format=".")
6363

6464
:marked
6565
Webpack inspects that file and traverses its `import` dependencies recursively.
6666

67-
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'app-example', 'src/app.ts')(format=".")
67+
+makeExample('webpack/ts/src/app/app.component.ts', 'component', 'src/main.ts')(format=".")
6868

6969
:marked
7070
It sees that you're importing *@angular/core* so it adds that to its dependency list for (potential) inclusion in the bundle.
71-
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.
71+
It opens the *@angular/core* file and follows _its_ network of `import` statements until it has built the complete dependency graph from `main.ts` down.
7272

7373
Then it **outputs** these files to the `app.js` _bundle file_ designated in configuration:
7474

75-
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'one-output', 'webpack.config.js (single output)')(format=".")
75+
.code-example
76+
code-example(name="webpack.config.js (single output)" language="javascript").
77+
output: {
78+
filename: 'app.js'
79+
}
7680

7781
:marked
7882
This `app.js` output bundle is a single JavaScript file that contains the application source and its dependencies.
@@ -82,9 +86,19 @@ a(id="entries-outputs")
8286
You probably don't want one giant bundle of everything.
8387
It's preferable to separate the volatile application app code from comparatively stable vendor code modules.
8488

85-
Change the configuration so that it has two entry points, `app.ts` and `vendor.ts`:
89+
Change the configuration so that it has two entry points, `main.ts` and `vendor.ts`:
90+
91+
.code-example
92+
code-example(language="javascript").
93+
entry: {
94+
app: 'src/app.ts',
95+
vendor: 'src/vendor.ts'
96+
},
97+
98+
output: {
99+
filename: '[name].js'
100+
}
86101

87-
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'two-entries','webpack.config.js (two entries)')(format=".")
88102
:marked
89103
Webpack constructs two separate dependency graphs
90104
and emits *two* bundle files, one called `app.js` containing only the application code and
@@ -110,13 +124,28 @@ a(id="loaders")
110124
Webpack _itself_ only understands JavaScript files.
111125
Teach it to transform non-JavaScript file into their JavaScript equivalents with *loaders*.
112126
Configure loaders for TypeScript and CSS as follows.
113-
114-
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'loaders', 'webpack.config.js (two entries)')(format=".")
127+
128+
.code-example
129+
code-example(language="javascript").
130+
rules: [
131+
{
132+
test: /\.ts$/,
133+
loader: 'awesome-typescript-loader'
134+
},
135+
{
136+
test: /\.css$/,
137+
loaders: 'style-loader!css-loader'
138+
}
139+
]
115140

116141
:marked
117142
As Webpack encounters `import` statements like these ...
118-
119-
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'imports')(format=".")
143+
144+
.code-example
145+
code-example(language="typescript").
146+
import { AppComponent } from './app.component.ts';
147+
148+
import 'uiframework/dist/uiframework.css';
120149

121150
:marked
122151
... it applies the `test` RegEx patterns. When a pattern matches the filename, Webpack processes the file with the associated loader.
@@ -137,7 +166,11 @@ a(id="plugins")
137166
Webpack has a build pipeline with well-defined phases.
138167
Tap into that pipeline with plugins such as the `uglify` minification plugin:
139168

140-
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'plugins')(format=".")
169+
.code-example
170+
code-example(language="javascript").
171+
plugins: [
172+
new webpack.optimize.UglifyJsPlugin()
173+
]
141174

142175
a(id="configure-webpack")
143176
.l-main-section
@@ -249,7 +282,10 @@ a#common-resolve
249282

250283
The app will `import` dozens if not hundreds of JavaScript and TypeScript files.
251284
You could write `import` statements with explicit extensions like this example:
252-
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'single-import')(format=".")
285+
286+
.code-example
287+
code-example(language="typescript").
288+
import { AppComponent } from './app.component.ts';
253289

254290
:marked
255291
But most `import` statements don't mention the extension at all.

0 commit comments

Comments
 (0)