build: move server rendering to dist (#4822)

* build: move server rendering to dist

* Verifying that Material works with `platform-server` now happens in the `dist/` folder (instead of the src/ folder)
* Adds a gulp task to build the universal application. In the future serving the app will be also part of this

* Address comments
This commit is contained in:
Paul Gschwendtner
2017-05-30 18:22:18 +02:00
committed by mmalerba
parent 12d6e968c2
commit fb5520cebf
11 changed files with 106 additions and 59 deletions
+1
View File
@@ -0,0 +1 @@
export * from './kitchen-sink/kitchen-sink';
+4 -3
View File
@@ -1,15 +1,16 @@
import 'reflect-metadata';
require('zone.js/dist/zone-node.js');
import 'zone.js';
import {enableProdMode} from '@angular/core';
import {renderModuleFactory} from '@angular/platform-server';
import {KitchenSinkServerModuleNgFactory} from './dist/aot/kitchen-sink/kitchen-sink.ngfactory';
import {join} from 'path';
import {readFileSync} from 'fs-extra';
import {KitchenSinkServerModuleNgFactory} from './kitchen-sink/kitchen-sink.ngfactory';
enableProdMode();
const result = renderModuleFactory(KitchenSinkServerModuleNgFactory, {
document: readFileSync('src/universal-app/index.html', 'utf-8')
document: readFileSync(join(__dirname, 'index.html'), 'utf-8')
});
result.then(html => console.log(html));
+29
View File
@@ -0,0 +1,29 @@
// TypeScript config file that is used to compile the universal-app.
{
"compilerOptions": {
"declaration": true,
"stripInternal": false,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "../../dist/packages/universal-app",
"rootDir": ".",
"sourceMap": true,
"target": "es2015",
"lib": ["es2015", "dom"],
"skipLibCheck": true,
"types": [],
"baseUrl": ".",
"paths": {
"@angular/material": ["./material"],
"@angular/cdk": ["./cdk"]
}
},
"files": [
"main.ts"
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"genDir": "../../dist/packages/universal-app"
}
}
-23
View File
@@ -1,23 +0,0 @@
{
"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"
}
}
+19 -9
View File
@@ -1,15 +1,25 @@
// TypeScript config file that is used to compile the files that prerender the Universal app.
{
"compilerOptions": {
"lib": ["es2015", "dom"],
"target": "es6",
"declaration": false,
"stripInternal": false,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
"noEmitOnError": true,
"noImplicitAny": true,
"sourceMap": false,
"experimentalDecorators": true,
"types": ["node"]
"outDir": ".",
"rootDir": ".",
"sourceMap": true,
"target": "es2015",
"lib": ["es2015", "dom"],
"skipLibCheck": true,
"types": [],
"baseUrl": ".",
"paths": {
"@angular/material": ["./material"],
"@angular/cdk": ["./cdk"]
}
},
"files": ["prerender.ts"]
"files": [
"prerender.ts"
]
}