mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
build: add ci task for server-side prerender (#4808)
This adds a new task for Travis CI to prerender an app using @angular/material. This change starts off by only adding buttons to the application; more components will be added in a subsequent PR so that this one stays focused on the set-up.
This commit is contained in:
committed by
tinayuangao
parent
7db2762d78
commit
97d69fb3f8
@@ -0,0 +1,11 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Angular Material Univeral Kitchen Sink Test</title>
|
||||
<base href="/">
|
||||
</head>
|
||||
<body>
|
||||
<kitchen-sink>Loading...</kitchen-sink>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,3 @@
|
||||
.kitchen-sink {
|
||||
color: lightsteelblue;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<h1>Kitchen sink app</h1>
|
||||
|
||||
<h2>Buttons</h2>
|
||||
|
||||
<button md-button>go</button>
|
||||
<button md-icon-button>go</button>
|
||||
<button md-raised-button>go</button>
|
||||
<button md-fab>go</button>
|
||||
<button md-mini-fab>go</button>
|
||||
|
||||
<a md-button href="https://google.com">Google</a>
|
||||
<a md-icon-button href="https://google.com">Google</a>
|
||||
<a md-raised-button href="https://google.com">Google</a>
|
||||
<a md-fab href="https://google.com">Google</a>
|
||||
<a md-mini-fab href="https://google.com">Google</a>
|
||||
@@ -0,0 +1,30 @@
|
||||
import {Component, NgModule} from '@angular/core';
|
||||
import {ServerModule} from '@angular/platform-server';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {MdButtonModule} from '@angular/material';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'kitchen-sink',
|
||||
templateUrl: './kitchen-sink.html',
|
||||
styleUrls: ['./kitchen-sink.css'],
|
||||
})
|
||||
export class KitchenSink { }
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
BrowserModule.withServerTransition({appId: 'kitchen-sink'}),
|
||||
MdButtonModule,
|
||||
],
|
||||
bootstrap: [KitchenSink],
|
||||
declarations: [KitchenSink],
|
||||
})
|
||||
export class KitchenSinkClientModule { }
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [KitchenSinkClientModule, ServerModule],
|
||||
bootstrap: [KitchenSink],
|
||||
})
|
||||
export class KitchenSinkServerModule { }
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'reflect-metadata';
|
||||
require('zone.js/dist/zone-node.js');
|
||||
|
||||
import {enableProdMode} from '@angular/core';
|
||||
import {renderModuleFactory} from '@angular/platform-server';
|
||||
import {KitchenSinkServerModuleNgFactory} from './dist/aot/kitchen-sink/kitchen-sink.ngfactory';
|
||||
import {readFileSync} from 'fs-extra';
|
||||
|
||||
enableProdMode();
|
||||
|
||||
const result = renderModuleFactory(KitchenSinkServerModuleNgFactory, {
|
||||
document: readFileSync('src/universal-app/index.html', 'utf-8')
|
||||
});
|
||||
|
||||
result.then(html => console.log(html));
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "es2015",
|
||||
"moduleResolution": "node",
|
||||
"target": "es6",
|
||||
"noImplicitAny": false,
|
||||
"sourceMap": false,
|
||||
"experimentalDecorators": true,
|
||||
"outDir": "dist",
|
||||
"declaration": true,
|
||||
"typeRoots": ["node_modules/@types"]
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"prerender.ts"
|
||||
],
|
||||
"angularCompilerOptions": {
|
||||
"annotationsAs": "static fields",
|
||||
"annotateForClosureCompiler": true,
|
||||
"genDir": "./dist/aot"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["es2015", "dom"],
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "dist",
|
||||
"noEmitOnError": true,
|
||||
"noImplicitAny": true,
|
||||
"sourceMap": false,
|
||||
"experimentalDecorators": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"files": ["prerender.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user