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

Commit 0e61a64

Browse files
feat(#7): sync website with last angular universal repo
1 parent 6c37e88 commit 0e61a64

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

angular.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
33
"version": 1,
44
"newProjectRoot": "projects",
55
"projects": {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
"bootstrap": "^4.1.3",
4747
"cookieconsent": "^3.1.0",
4848
"core-js": "^2.5.7",
49+
"express": "^4.16.3",
50+
"reflect-metadata": "^0.1.12",
4951
"hammerjs": "^2.0.8",
5052
"moment": "^2.22.2",
5153
"ngx-markdown": "^6.2.1",
@@ -66,12 +68,10 @@
6668
"codelyzer": "^4.4.4",
6769
"cpy-cli": "^2.0.0",
6870
"del": "^3.0.0",
69-
"express": "^4.16.3",
7071
"gulp": "^3.9.1",
7172
"gulp-remove-code": "^3.0.4",
7273
"http-server": "^0.11.1",
7374
"pre-commit": "^1.2.2",
74-
"reflect-metadata": "^0.1.12",
7575
"replace": "1.0.0",
7676
"ts-loader": "^5.2.1",
7777
"tslint": "^5.11.0",

server.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,57 @@
11
import 'zone.js/dist/zone-node';
22
import 'reflect-metadata';
3-
import {enableProdMode} from '@angular/core';
3+
import { enableProdMode } from '@angular/core';
4+
45
// Express Engine
5-
import {ngExpressEngine} from '@nguniversal/express-engine';
6+
import { ngExpressEngine } from '@nguniversal/express-engine';
67
// Import module map for lazy loading
7-
import {provideModuleMap} from '@nguniversal/module-map-ngfactory-loader';
8+
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';
89

910
import * as express from 'express';
10-
import {join} from 'path';
11+
import { join } from 'path';
1112

1213
// Faster server renders w/ Prod mode (dev mode never needed)
1314
enableProdMode();
1415

1516
// Express server
1617
const app = express();
1718

18-
const PORT = process.env.PORT || 8000;
19+
const PORT = process.env.PORT || 4000;
1920
const DIST_FOLDER = join(process.cwd(), 'dist');
2021

2122
// * NOTE :: leave this as require() since this file is built Dynamically from webpack
22-
const {AppServerModuleNgFactory, LAZY_MODULE_MAP} = require('./server/main');
23+
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./server/main');
2324

2425
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
2526
app.engine('html', ngExpressEngine({
2627
bootstrap: AppServerModuleNgFactory,
2728
providers: [
28-
provideModuleMap(LAZY_MODULE_MAP)
29+
provideModuleMap(LAZY_MODULE_MAP),
30+
// In case you want to use an AppShell with SSR and Lazy loading
31+
// you'd need to uncomment the below. (see: https://github.com/angular/angular-cli/issues/9202)
32+
// {
33+
// provide: NgModuleFactoryLoader,
34+
// useClass: ModuleMapNgFactoryLoader,
35+
// deps: [
36+
// Compiler,
37+
// MODULE_MAP
38+
// ],
39+
// },
2940
]
3041
}));
3142

3243
app.set('view engine', 'html');
3344
app.set('views', join(DIST_FOLDER, 'browser'));
3445

35-
/* - Example Express Rest API endpoints -
36-
app.get('/api/**', (req, res) => { });
37-
*/
46+
// Example Express Rest API endpoints
47+
// app.get('/api/**', (req, res) => { });
3848

3949
// Server static files from /browser
4050
app.get('*.*', express.static(join(DIST_FOLDER, 'browser'), {
4151
maxAge: '1y'
4252
}));
4353

44-
// ALl regular routes use the Universal engine
54+
// All regular routes use the Universal engine
4555
app.get('*', (req, res) => {
4656
res.render('index', { req });
4757
});

src/environments/environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// The file contents for the current environment will overwrite these during build.
22
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
33
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
4-
// The list of which env maps to which file can be found in `.angular-cli.json`.
4+
// The list of which env maps to which file can be found in `.angular.json`.
55

66
export const environment = {
77
production: false

0 commit comments

Comments
 (0)