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

Commit 9b27bfb

Browse files
committed
docs(webpack): checkin missing snippets; .js->.ts
closes #1375
1 parent 024b680 commit 9b27bfb

File tree

2 files changed

+67
-8
lines changed

2 files changed

+67
-8
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/* tslint:disable */
2+
// #docregion one-entry
3+
entry: {
4+
app: 'src/app.ts'
5+
}
6+
// #enddocregion one-entry
7+
8+
// #docregion app-example
9+
import { Component } from '@angular/core';
10+
11+
@Component({
12+
...
13+
})
14+
export class AppComponent {}
15+
// #enddocregion app-example
16+
17+
// #docregion one-output
18+
output: {
19+
filename: 'app.js'
20+
}
21+
// #enddocregion one-output
22+
23+
// #docregion two-entries
24+
entry: {
25+
app: 'src/app.ts',
26+
vendor: 'src/vendor.ts'
27+
},
28+
29+
output: {
30+
filename: '[name].js'
31+
}
32+
// #enddocregion two-entries
33+
34+
// #docregion loaders
35+
loaders: [
36+
{
37+
test: /\.ts$/
38+
loaders: 'ts'
39+
},
40+
{
41+
test: /\.css$/
42+
loaders: 'style!css'
43+
}
44+
]
45+
// #enddocregion loaders
46+
47+
// #docregion imports
48+
// #docregion single-import
49+
import { AppComponent } from './app.component.ts';
50+
// #enddocregion single-import
51+
import 'uiframework/dist/uiframework.css';
52+
// #enddocregion imports
53+
54+
// #docregion plugins
55+
plugins: [
56+
new webpack.optimize.UglifyJsPlugin()
57+
]
58+
// #enddocregion plugins
59+
// #enddocregion

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,20 @@ a(id="entries-outputs")
5252
We feed Webpack with one or more *entry* files and let it find and incorporate the dependencies that radiate from those entries.
5353
In this example, we start from the application's root file, `src/app.ts`:
5454

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

5757
:marked
5858
Webpack inspects that file and traverses its `import` dependencies recursively.
5959

60-
+makeExample('webpack/ts-snippets/webpack.config.snippets.js', 'app-example', 'src/app.ts')(format=".")
60+
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'app-example', 'src/app.ts')(format=".")
6161

6262
:marked
6363
Here it sees that we're importing *@angular/core* so it adds that to its dependency list for (potential) inclusion in the bundle.
6464
It opens *@angular/core* and follows _its_ network of `import` statements until it has build the complete dependency graph from `app.ts` down.
6565

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

68-
+makeExample('webpack/ts-snippets/webpack.config.snippets.js', 'one-output', 'webpack.config.js (single output)')(format=".")
68+
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'one-output', 'webpack.config.js (single output)')(format=".")
6969

7070
:marked
7171
This `app.js` output bundle is a single JavaScript file that contains our application source and its dependencies.
@@ -77,7 +77,7 @@ a(id="entries-outputs")
7777

7878
We change the configuration so that we have two entry points, `app.ts` and `vendor.ts`:
7979

80-
+makeExample('webpack/ts-snippets/webpack.config.snippets.js', 'two-entries','webpack.config.js (two entries)')(format=".")
80+
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'two-entries','webpack.config.js (two entries)')(format=".")
8181
:marked
8282
Webpack constructs two separate dependency graphs
8383
and emits *two* bundle files, one called `app.js` containing only our application code and
@@ -105,12 +105,12 @@ a(id="loaders")
105105
We teach it to process such files into JavaScript with *loaders*.
106106
Here we configure loaders for TypeScript and CSS:
107107

108-
+makeExample('webpack/ts-snippets/webpack.config.snippets.js', 'loaders', 'webpack.config.js (two entries)')(format=".")
108+
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'loaders', 'webpack.config.js (two entries)')(format=".")
109109

110110
:marked
111111
As Webpack encounters `import` statements like these ...
112112

113-
+makeExample('webpack/ts-snippets/webpack.config.snippets.js', 'imports')(format=".")
113+
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'imports')(format=".")
114114

115115
:marked
116116
... it applies the `test` RegEx patterns. When a pattern matches the filename, Webpack processes the file with the associated loader.
@@ -131,7 +131,7 @@ a(id="plugins")
131131
Webpack has a build pipeline with well-defined phases.
132132
We tap into that pipeline with plugins such as the `uglify` minification plugin:
133133

134-
+makeExample('webpack/ts-snippets/webpack.config.snippets.js', 'plugins')(format=".")
134+
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'plugins')(format=".")
135135

136136
a(id="configure-webpack")
137137
.l-main-section
@@ -212,7 +212,7 @@ a(id="common-configuration")
212212
:marked
213213
Our app will `import` dozens if not hundreds of JavaScript and TypeScript files.
214214
We _might_ write `import` statements with explicit extensions as in this example:
215-
+makeExample('webpack/ts-snippets/webpack.config.snippets.js', 'single-import')(format=".")
215+
+makeExample('webpack/ts-snippets/webpack.config.snippets.ts', 'single-import')(format=".")
216216

217217
:marked
218218
But most of our `import` statements won't mention the extension at all.

0 commit comments

Comments
 (0)