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

feat(prod-deploy): add prod deploy chapter #3043

Merged
merged 7 commits into from
Jan 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/docs/_examples/deployment/ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!systemjs.config.server.js
15 changes: 15 additions & 0 deletions public/docs/_examples/deployment/ts/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// #docregion
import { Component } from '@angular/core';

@Component({
selector: 'my-app',
template: `
<h1>Simple Deployment</h1>
<nav>
<a routerLink="/crisis-center" routerLinkActive="active">Crisis Center</a>
<a routerLink="/heroes" routerLinkActive="active">Heroes</a>
</nav>
<router-outlet></router-outlet>
`
})
export class AppComponent { }
29 changes: 29 additions & 0 deletions public/docs/_examples/deployment/ts/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// #docregion
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule, Routes } from '@angular/router';

import { AppComponent } from './app.component';
import { CrisisListComponent } from './crisis-list.component';
import { HeroListComponent } from './hero-list.component';

const appRoutes: Routes = [
{ path: 'crisis-center', component: CrisisListComponent },
{ path: 'heroes', component: HeroListComponent },

{ path: '', redirectTo: '/heroes', pathMatch: 'full' }
];

@NgModule({
imports: [
BrowserModule,
RouterModule.forRoot(appRoutes)
],
declarations: [
AppComponent,
CrisisListComponent,
HeroListComponent
],
bootstrap: [ AppComponent ]
})
export class AppModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// #docregion
import { Component } from '@angular/core';

@Component({
template: `
<h2>CRISIS CENTER</h2>
<p>Get your crisis here</p>`
})
export class CrisisListComponent { }
10 changes: 10 additions & 0 deletions public/docs/_examples/deployment/ts/app/hero-list.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// #docregion
import { Component } from '@angular/core';

@Component({
template: `
<h2>HEROES</h2>
<p>Get your heroes here</p>
`
})
export class HeroListComponent { }
15 changes: 15 additions & 0 deletions public/docs/_examples/deployment/ts/app/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// #docregion
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app.module';

// #docregion enableProdMode
import { enableProdMode } from '@angular/core';

// Enable production mode unless running locally
if (!/localhost/.test(document.location.host)) {
enableProdMode();
}
// #enddocregion enableProdMode

platformBrowserDynamic().bootstrapModule(AppModule);
Empty file.
38 changes: 38 additions & 0 deletions public/docs/_examples/deployment/ts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!-- #docregion -->
<!DOCTYPE html>
<html>
<head>
<!- Doesn't load from node_modules! -->

<!-- Set the base href -->
<base href="/">
<title>Simple Deployment</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">

<!-- #docregion node-module-scripts -->
<!-- Polyfills for older browsers -->
<script src="https://unpkg.com/core-js/client/shim.min.js"></script>

<!-- Update these package versions as needed -->
<script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script>
<script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js"></script>
<!-- #enddocregion node-module-scripts -->

<!-- #docregion systemjs-config -->
<!-- This SystemJS configuration loads umd packages from the web -->
<script src="systemjs.config.server.js"></script>
<!-- #enddocregion systemjs-config -->

<script>
System.import('app')
.catch(function(err){ console.error(err); });
</script>
</head>

<body>
<my-app>loading...</my-app>
</body>

</html>
46 changes: 46 additions & 0 deletions public/docs/_examples/deployment/ts/systemjs.config.server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// #docregion
/**
* System configuration for deployment without installing node_modules
* Loads umd packages from the web instead
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
// #docregion paths
paths: {
'npm:': 'https://unpkg.com/' // path serves as alias
},
// #enddocregion paths
// map tells the System loader where to look for things
map: {
app: 'app', // location of transpiled app files

// angular minimized umd bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.min.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.min.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.min.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.min.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.min.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.min.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.min.js',
'@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.min.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.min.js',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.min.js',
'@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.min.js',

// other libraries
'rxjs': 'npm:rxjs@5.0.1',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);
5 changes: 5 additions & 0 deletions public/docs/ts/latest/guide/_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@
"intro": "Pipes transform displayed values within a template."
},

"production-deploy": {
"title": "Deployment",
"intro": "Learn how to deploy your Angular app."
},

"router": {
"title": "Routing & Navigation",
"intro": "Discover the basics of screen navigation with the Angular Router."
Expand Down
Loading