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

Commit 341f32d

Browse files
Foxandxsswardbell
authored andcommitted
docs(webpack): add angular2-template-loader
closes #1825
1 parent 67ee007 commit 341f32d

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

public/docs/_examples/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
},
4646
"devDependencies": {
4747
"angular-cli": "^1.0.0-beta.5",
48+
"angular2-template-loader": "^0.4.0",
4849
"canonical-path": "0.0.2",
4950
"concurrently": "^2.1.0",
5051
"css-loader": "^0.23.1",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = {
2424
loaders: [
2525
{
2626
test: /\.ts$/,
27-
loader: 'ts'
27+
loaders: ['ts', 'angular2-template-loader']
2828
},
2929
{
3030
test: /\.html$/,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
loaders: [
1111
{
1212
test: /\.ts$/,
13-
loader: 'ts'
13+
loaders: ['ts', 'angular2-template-loader']
1414
},
1515
{
1616
test: /\.html$/,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import '../../public/css/styles.css';
55

66
@Component({
77
selector: 'my-app',
8-
template: require('./app.component.html'),
9-
styles: [require('./app.component.css')]
8+
templateUrl: './app.component.html',
9+
styleUrls: ['./app.component.css']
1010
})
1111
export class AppComponent { }
1212
// #enddocregion

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,10 @@ a(id="common-configuration")
233233

234234
:marked
235235
* ts - a loader to transpile our Typescript code to ES5, guided by the `tsconfig.json` file
236+
* angular2-template-loader - loads angular components' template and styles
236237
* html - for component templates
237238
* images/fonts - Images and fonts are bundled as well.
238-
* css - The pattern matches application-wide styles; the second handles component-scoped styles (the ones specified in a component's `styleUrls` metadata property).
239+
* css - The pattern matches application-wide styles; the second handles component-scoped styles (the ones specified in a component's `styleUrls` metadata property)
239240
.l-sub-section
240241
:marked
241242
The first pattern excludes `.css` files within the `/src/app` directories where our component-scoped styles sit.
@@ -245,6 +246,10 @@ a(id="common-configuration")
245246
The second pattern filters for component-scoped styles and loads them as strings via the `raw` loader —
246247
which is what Angular expects to do with styles specified in a `styleUrls` metadata property.
247248

249+
.l-sub-section
250+
:marked
251+
Multiple loaders can be also chained using the array notation.
252+
248253
:marked
249254
Finally we add two plugins:
250255

@@ -441,9 +446,10 @@ p.
441446
The `HtmlWebpackPlugin` inserts them dynamically at runtime.
442447

443448
* The `AppComponent` in `app.component.ts` imports the application-wide css with a simple `import` statement.
444-
445-
* The `AppComponent` itself has its own html template and css files which we load with the `require()` method
446-
supplied by Webpack. Webpack stashes those component-scoped files in the `app.js` bundle too.
449+
450+
* The `AppComponent` itself has its own html template and css file. WebPack loads them with calls to `require()`.
451+
Webpack stashes those component-scoped files in the `app.js` bundle too.
452+
We don't see those calls in our source code; they're added behind the scenes by the `angular2-template-loader` plug-in.
447453

448454
* The `vendor.ts` consists of vendor dependency `import` statements that drive the `vendor.js` bundle.
449455
The application imports these modules too; they'd be duplicated in the `app.js` bundle

0 commit comments

Comments
 (0)