Skip to content
This repository was archived by the owner on Jan 12, 2019. It is now read-only.

Commit 83f9733

Browse files
committed
Google Cloud Deployment feature added
1 parent fcce863 commit 83f9733

File tree

7 files changed

+120
-8
lines changed

7 files changed

+120
-8
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# compiled output
2-
/dist
2+
/public/dist
3+
/public/etc
34
/tmp
45
/out-tsc
56

@@ -16,8 +17,8 @@
1617
*.sublime-workspace
1718

1819
# IDE - VSCode
20+
.vscode
1921
.vscode/*
20-
.vscode/
2122
!.vscode/settings.json
2223
!.vscode/tasks.json
2324
!.vscode/launch.json

angular-cli.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"apps": [
77
{
88
"root": "src",
9-
"outDir": "dist/browser",
9+
"outDir": "public/dist/browser",
1010
"assets": ["assets", "favicon.ico"],
1111
"index": "index.html",
1212
"main": "main.ts",
@@ -26,7 +26,7 @@
2626
},
2727
{
2828
"root": "src",
29-
"outDir": "dist/server",
29+
"outDir": "public/dist/server",
3030
"assets": ["assets", "favicon.ico"],
3131
"platform": "server",
3232
"index": "index.html",

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
"build:universal":
1515
"npm run build:client && npm run build:server && npm run build:webpack",
1616

17-
"serve:universal": "node dist/server.js",
17+
"serve:universal": "npm start --prefix ./public/",
1818

1919
"deploy:dev":
20-
"ng build --prod --aot --base-href http://www.voraknotech.com/angular-scaffolding/ && ngh --dir=dist/browser/"
20+
"ng build --prod --aot --base-href http://www.voraknotech.com/angular-scaffolding/ && ngh --dir=public/dist/browser/",
21+
"deploy:prod": "npm run build:universal && ngh --dir=public/ --branch=prod"
2122
},
2223
"private": true,
2324
"dependencies": {

public/app.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# [START app_yaml]
2+
runtime: nodejs
3+
env: flex
4+
5+
# This sample incurs costs to run on the App Engine flexible environment.
6+
# The settings below are to reduce costs during testing and are not appropriate
7+
# for production use
8+
manual_scaling:
9+
instances: 1
10+
resources:
11+
cpu: 1
12+
memory_gb: 0.5
13+
disk_size_gb: 10
14+
15+
# [END app_yaml]

public/package.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "angular-scaffolding",
3+
"version": "0.0.0",
4+
"license": "MIT",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/voraknotech/angular-scaffolding"
8+
},
9+
"contributors": ["Abhijit Kar"],
10+
"scripts": {
11+
"deploy:gcloud": "gcloud app deploy -v prod",
12+
"start": "node ./dist/server.js"
13+
},
14+
"engines": {
15+
"node": "6.11.4",
16+
"npm": "3.10.10"
17+
},
18+
"dependencies": {
19+
"@angular/animations": "^5.1.2",
20+
"@angular/common": "^5.1.2",
21+
"@angular/compiler": "^5.1.2",
22+
"@angular/core": "^5.1.2",
23+
"@angular/forms": "^5.1.2",
24+
"@angular/http": "^5.1.2",
25+
"@angular/platform-browser": "^5.1.2",
26+
"@angular/platform-browser-dynamic": "^5.1.2",
27+
"@angular/platform-server": "^5.1.2",
28+
"@angular/router": "^5.1.2",
29+
"@angular/service-worker": "^5.1.2",
30+
"@nguniversal/express-engine": "^5.0.0-beta.5",
31+
"@nguniversal/module-map-ngfactory-loader": "^5.0.0-beta.5",
32+
"compression": "^1.7.1",
33+
"core-js": "^2.5.3",
34+
"express": "^4.16.2",
35+
"global": "^4.3.2",
36+
"gsap": "^1.20.3",
37+
"heap": "^0.2.6",
38+
"lodash": "^4.17.4",
39+
"reflect-metadata": "^0.1.10",
40+
"rxjs": "^5.5.6",
41+
"ts-loader": "^3.2.0",
42+
"zone.js": "^0.8.18"
43+
},
44+
"devDependencies": {
45+
"@google-cloud/nodejs-repo-tools": "1.4.17"
46+
}
47+
}

public/server.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { renderModuleFactory } from "@angular/platform-server";
2+
import { enableProdMode } from "@angular/core";
3+
import { ngExpressEngine } from "@nguniversal/express-engine";
4+
import { provideModuleMap } from "@nguniversal/module-map-ngfactory-loader";
5+
import "zone.js/dist/zone-node";
6+
import "reflect-metadata";
7+
8+
import * as express from "express";
9+
import { join } from "path";
10+
import { readFileSync } from "fs";
11+
var compression = require("compression");
12+
13+
enableProdMode();
14+
15+
const app = express();
16+
const PORT = process.env.PORT || 8080;
17+
const DIST_FOLDER = join(process.cwd(), "dist");
18+
const {
19+
AppServerModuleNgFactory,
20+
LAZY_MODULE_MAP
21+
} = require("./dist/server/main.bundle");
22+
23+
app.use(compression());
24+
app.engine(
25+
"html",
26+
ngExpressEngine({
27+
bootstrap: AppServerModuleNgFactory,
28+
providers: [provideModuleMap(LAZY_MODULE_MAP)]
29+
})
30+
);
31+
32+
app.set("view engine", "html");
33+
app.set("views", join(DIST_FOLDER, "browser"));
34+
35+
app.use(
36+
express.static(join(DIST_FOLDER, "browser"), {
37+
index: false,
38+
maxAge: "1y"
39+
})
40+
);
41+
42+
app.get("*", (req, res) => {
43+
res.render(join(DIST_FOLDER, "browser", "index.html"), { req });
44+
});
45+
46+
app.listen(PORT, () => {
47+
console.log(`Node Express server listening on http://localhost:${PORT}`);
48+
});

webpack.server.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ const path = require("path");
22
const webpack = require("webpack");
33

44
module.exports = {
5-
entry: { server: "./server.ts" },
5+
entry: { server: "./public/server.ts" },
66
resolve: { extensions: [".js", ".ts"] },
77
target: "node",
88
// this makes sure we include node_modules and other 3rd party libraries
99
externals: [/(node_modules|main\..*\.js)/],
1010
output: {
11-
path: path.join(__dirname, "dist"),
11+
path: path.join(__dirname, "./public/dist"),
1212
filename: "[name].js"
1313
},
1414
module: {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy