Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

WIP: feat(build): add config for universal watch mode #658

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
36 changes: 36 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,42 @@
"root": "",
"projectType": "application",
"architect": {
"ssrWatch": {
"builder": "@nguniversal/builders:ssr",
"options": {
"browserTarget": "ng-universal-demo:build",
"universalTarget": "ng-universal-demo:server",
"ssrExecuteTarget": "ng-universal-demo:ssrExecute"
}
},
"ssrBuild": {
"builder": "@nrwl/builders:node-build",
"options": {
"main": "server.ts",
"tsConfig": "tsconfig.json",
"outputPath": "dist/ssr"
}
},
"ssrExecute": {
"builder": "@nrwl/builders:node-execute",
"options": {
"buildTarget": "ng-universal-demo:ssrBuild"
}
},
"prerenderBuild": {
"builder": "@nrwl/builders:node-build",
"options": {
"main": "prerender.ts",
"tsConfig": "tsconfig.json",
"outputPath": "dist/prerender"
}
},
"prerenderExecute": {
"builder": "@nrwl/builders:node-execute",
"options": {
"buildTarget": "ng-universal-demo:prerenderBuild"
}
},
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
Expand Down
Binary file added nguniversal-builders-0.1.0.tgz
Binary file not shown.
49 changes: 24 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,46 @@
"start": "ng serve",
"build": "ng build",
"lint": "ng lint ng-universal-demo",
"build:client-and-server-bundles": "ng build --prod && ng run ng-universal-demo:server:production",
"build:prerender": "npm run build:client-and-server-bundles && npm run compile:server && npm run generate:prerender",
"build:ssr": "npm run build:client-and-server-bundles && npm run compile:server",
"compile:server": "tsc -p server.tsconfig.json",
"generate:prerender": "cd dist && node prerender",
"serve:prerender": "cd dist/browser && http-server",
"serve:ssr": "node dist/server"
"build:prerender": "ng run ng-universal-demo:build && ng run ng-universal-demo:server && ng run ng-universal-demo:prerenderBuild && node dist/prerender/main.js",
"serve:prerender": "npm run build:prerender && cd dist/browser && http-server",
"build:ssr": "ng run ng-universal-demo:build && ng run ng-universal-demo:server && ng run ng-universal-demo:ssrBuild",
"serve:ssr": "ng run ng-universal-demo:ssrWatch"
},
"pre-commit": [],
"private": true,
"dependencies": {
"@angular/animations": "^6.0.0",
"@angular/common": "^6.0.0",
"@angular/compiler": "^6.0.0",
"@angular/core": "^6.0.0",
"@angular/forms": "^6.0.0",
"@angular/http": "^6.0.0",
"@angular/platform-browser": "^6.0.0",
"@angular/platform-browser-dynamic": "^6.0.0",
"@angular/platform-server": "^6.0.0",
"@angular/router": "^6.0.0",
"@nguniversal/common": "^6.0.0",
"@nguniversal/express-engine": "^6.0.0",
"@nguniversal/module-map-ngfactory-loader": "^6.0.0",
"@angular/animations": "~7.1.4",
"@angular/common": "~7.1.4",
"@angular/compiler": "~7.1.4",
"@angular/core": "~7.1.4",
"@angular/forms": "~7.1.4",
"@angular/http": "~7.1.4",
"@angular/platform-browser": "~7.1.4",
"@angular/platform-browser-dynamic": "~7.1.4",
"@angular/platform-server": "~7.1.4",
"@angular/router": "~7.1.4",
"@nguniversal/common": "~7.0.2",
"@nguniversal/express-engine": "~7.0.2",
"@nguniversal/module-map-ngfactory-loader": "~7.0.2",
"@nguniversal/builders": "file:./nguniversal-builders-0.1.0.tgz",
"@nrwl/builders": "^7.1.1",
"core-js": "^2.4.1",
"express": "^4.15.2",
"reflect-metadata": "^0.1.10",
"rxjs": "^6.2.2",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "0.6.0",
"@angular/cli": "6.0.0",
"@angular/compiler-cli": "^6.0.0",
"@angular/language-service": "^6.0.0",
"@angular-devkit/build-angular": "0.11.4",
"@angular/cli": "~7.1.4",
"@angular/compiler-cli": "~7.1.4",
"@angular/language-service": "~7.1.4",
"@types/node": "^8.0.30",
"codelyzer": "^4.0.2",
"http-server": "^0.10.0",
"pre-commit": "^1.2.2",
"ts-loader": "^4.2.0",
"tslint": "^5.7.0",
"typescript": "~2.7.2"
"typescript": "~3.1.1"
}
}
8 changes: 4 additions & 4 deletions prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import {provideModuleMap} from '@nguniversal/module-map-ngfactory-loader';
import {renderModuleFactory} from '@angular/platform-server';
import {ROUTES} from './static.paths';

// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const {AppServerModuleNgFactory, LAZY_MODULE_MAP} = require('./server/main');
// NOTE: this will be an error in your console until the universal bundle is built
import { AppServerModuleNgFactory, LAZY_MODULE_MAP } from './dist/server/main';

const BROWSER_FOLDER = join(process.cwd(), 'browser');
const BROWSER_FOLDER = join(process.cwd(), 'dist', 'browser');

// Load the index.html file containing referances to your application bundle.
const index = readFileSync(join('browser', 'index.html'), 'utf8');
const index = readFileSync(join(BROWSER_FOLDER, 'index.html'), 'utf8');

let previousRender = Promise.resolve();

Expand Down
4 changes: 2 additions & 2 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const app = express();
const PORT = process.env.PORT || 4000;
const DIST_FOLDER = join(process.cwd(), 'dist');

// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./server/main');
// NOTE: this will be an error in your console until the universal bundle is built
import { AppServerModuleNgFactory, LAZY_MODULE_MAP } from './dist/server/main';

// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
app.engine('html', ngExpressEngine({
Expand Down
Loading