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

Commit 8f6f225

Browse files
committed
docs(prod-deploy): add sample for simplest deploy
1 parent 51e2395 commit 8f6f225

File tree

9 files changed

+167
-0
lines changed

9 files changed

+167
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// #docregion
2+
import { Component } from '@angular/core';
3+
4+
@Component({
5+
selector: 'my-app',
6+
template: `
7+
<h1>Production Deployment Sample</h1>
8+
<nav>
9+
<a routerLink="/crisis-center" routerLinkActive="active">Crisis Center</a>
10+
<a routerLink="/heroes" routerLinkActive="active">Heroes</a>
11+
</nav>
12+
<router-outlet></router-outlet>
13+
`
14+
})
15+
export class AppComponent { }
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// #docregion
2+
import { NgModule } from '@angular/core';
3+
import { BrowserModule } from '@angular/platform-browser';
4+
import { RouterModule, Routes } from '@angular/router';
5+
6+
import { AppComponent } from './app.component';
7+
import { HeroListComponent } from './hero-list.component';
8+
import { CrisisListComponent } from './crisis-list.component';
9+
import { PageNotFoundComponent } from './not-found.component';
10+
11+
const appRoutes: Routes = [
12+
{ path: 'crisis-center', component: CrisisListComponent },
13+
{ path: 'heroes', component: HeroListComponent },
14+
15+
{ path: '', redirectTo: '/heroes', pathMatch: 'full' },
16+
{ path: '**', component: PageNotFoundComponent }
17+
];
18+
19+
@NgModule({
20+
imports: [
21+
BrowserModule,
22+
RouterModule.forRoot(appRoutes)
23+
],
24+
declarations: [
25+
AppComponent,
26+
HeroListComponent,
27+
CrisisListComponent,
28+
PageNotFoundComponent
29+
],
30+
bootstrap: [ AppComponent ]
31+
})
32+
export class AppModule { }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// #docregion
2+
import { Component } from '@angular/core';
3+
4+
@Component({
5+
template: `
6+
<h2>CRISIS CENTER</h2>
7+
<p>Get your crisis here</p>`
8+
})
9+
export class CrisisListComponent { }
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// #docregion
2+
import { Component } from '@angular/core';
3+
4+
@Component({
5+
template: `
6+
<h2>HEROES</h2>
7+
<p>Get your heroes here</p>
8+
`
9+
})
10+
export class HeroListComponent { }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// #docregion
2+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3+
4+
import { AppModule } from './app.module';
5+
6+
// #docregion enableProdMode
7+
import { enableProdMode } from '@angular/core';
8+
9+
// Enable production mode unless running locally
10+
if (!/localhost/.test(document.location.host)) {
11+
enableProdMode();
12+
}
13+
// #enddocregion enableProdMode
14+
15+
platformBrowserDynamic().bootstrapModule(AppModule);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// #docregion
2+
import { Component } from '@angular/core';
3+
4+
@Component({
5+
template: '<h2>Page not found</h2>'
6+
})
7+
export class PageNotFoundComponent {}

public/docs/_examples/production-deploy/ts/example-config.json

Whitespace-only changes.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!-- #docregion -->
2+
<!DOCTYPE html>
3+
<html>
4+
<head>
5+
<!- Simplest Deployment Possible doesn't load from node_modules! -->
6+
7+
<!-- Set the base href -->
8+
<base href="/">
9+
<title>Simplest Deployment Possible</title>
10+
<meta charset="UTF-8">
11+
<meta name="viewport" content="width=device-width, initial-scale=1">
12+
<link rel="stylesheet" href="styles.css">
13+
14+
<!-- Polyfills for older browsers -->
15+
<script src="https://unpkg.com/core-js/client/shim.min.js"></script>
16+
17+
<script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script>
18+
<script src="https://unpkg.com/reflect-metadata@0.1.8"></script>
19+
<script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js"></script>
20+
21+
<!-- SystemJS configuration loads umd packages from the web -->
22+
<script src="systemjs.config.server.js"></script>
23+
<script>
24+
System.import('app')
25+
.catch(function(err){ console.error(err); });
26+
</script>
27+
</head>
28+
29+
<body>
30+
<my-app>loading...</my-app>
31+
</body>
32+
33+
</html>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// #docregion
2+
/**
3+
* System configuration for deployment without installing node_modules
4+
* Loads umd packages from the web instead
5+
* Adjust as necessary for your application needs.
6+
*/
7+
(function (global) {
8+
System.config({
9+
paths: {
10+
// paths serve as alias
11+
'npm:': 'https://unpkg.com/'
12+
},
13+
// map tells the System loader where to look for things
14+
map: {
15+
// our app is within the app folder
16+
app: 'app',
17+
18+
// angular bundles
19+
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
20+
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
21+
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
22+
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
23+
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
24+
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
25+
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
26+
'@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
27+
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
28+
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
29+
'@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
30+
31+
// other libraries
32+
'rxjs': 'npm:rxjs@5.0.1',
33+
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
34+
},
35+
// packages tells the System loader how to load when no filename and/or no extension
36+
packages: {
37+
app: {
38+
main: './main.js',
39+
defaultExtension: 'js'
40+
},
41+
rxjs: {
42+
defaultExtension: 'js'
43+
}
44+
}
45+
});
46+
})(this);

0 commit comments

Comments
 (0)