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

Commit f82bbc1

Browse files
authored
fix(style): add SSR capabilities (#962)
Fixes #813
1 parent c922ae3 commit f82bbc1

26 files changed

+250
-151
lines changed

src/apps/universal-app/.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Editor configuration, see http://editorconfig.org
1+
# Editor configuration, see https://editorconfig.org
22
root = true
33

44
[*]

src/apps/universal-app/.gitignore

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
8+
# dependencies
9+
/node_modules
10+
11+
# profiling files
12+
chrome-profiler-events.json
13+
speed-measure-plugin.json
14+
15+
# IDEs and editors
16+
/.idea
17+
.project
18+
.classpath
19+
.c9/
20+
*.launch
21+
.settings/
22+
*.sublime-workspace
23+
24+
# IDE - VSCode
25+
.vscode/*
26+
!.vscode/settings.json
27+
!.vscode/tasks.json
28+
!.vscode/launch.json
29+
!.vscode/extensions.json
30+
31+
# misc
32+
/.sass-cache
33+
/connect.lock
34+
/coverage
35+
/libpeerconnection.log
36+
npm-debug.log
37+
yarn-error.log
38+
testem.log
39+
/typings
40+
41+
# System Files
42+
.DS_Store
43+
Thumbs.db

src/apps/universal-app/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# UniversalApp
22

3-
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.6.6.
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.1.2.
44

55
## Development server
66

@@ -12,7 +12,7 @@ Run `ng generate component component-name` to generate a new component. You can
1212

1313
## Build
1414

15-
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
15+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
1616

1717
## Running unit tests
1818

src/apps/universal-app/angular.json

+44-27
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@
77
"root": "",
88
"sourceRoot": "src",
99
"projectType": "application",
10+
"prefix": "app",
11+
"schematics": {
12+
"@schematics/angular:component": {
13+
"styleext": "scss"
14+
}
15+
},
1016
"architect": {
1117
"build": {
1218
"builder": "@angular-devkit/build-angular:browser",
1319
"options": {
1420
"outputPath": "dist/browser",
1521
"index": "src/index.html",
1622
"main": "src/main.ts",
17-
"tsConfig": "src/tsconfig.app.json",
1823
"polyfills": "src/polyfills.ts",
24+
"tsConfig": "src/tsconfig.app.json",
1925
"assets": [
20-
"src/assets",
21-
"src/favicon.ico"
26+
"src/favicon.ico",
27+
"src/assets"
2228
],
2329
"styles": [
2430
"src/styles.scss"
@@ -27,6 +33,12 @@
2733
},
2834
"configurations": {
2935
"production": {
36+
"fileReplacements": [
37+
{
38+
"replace": "src/environments/environment.ts",
39+
"with": "src/environments/environment.prod.ts"
40+
}
41+
],
3042
"optimization": true,
3143
"outputHashing": "all",
3244
"sourceMap": false,
@@ -36,10 +48,11 @@
3648
"extractLicenses": true,
3749
"vendorChunk": false,
3850
"buildOptimizer": true,
39-
"fileReplacements": [
51+
"budgets": [
4052
{
41-
"replace": "src/environments/environment.ts",
42-
"with": "src/environments/environment.prod.ts"
53+
"type": "initial",
54+
"maximumWarning": "2mb",
55+
"maximumError": "5mb"
4356
}
4457
]
4558
}
@@ -66,16 +79,16 @@
6679
"builder": "@angular-devkit/build-angular:karma",
6780
"options": {
6881
"main": "src/test.ts",
69-
"karmaConfig": "./karma.conf.js",
7082
"polyfills": "src/polyfills.ts",
7183
"tsConfig": "src/tsconfig.spec.json",
72-
"scripts": [],
84+
"karmaConfig": "src/karma.conf.js",
7385
"styles": [
7486
"src/styles.scss"
7587
],
88+
"scripts": [],
7689
"assets": [
77-
"src/assets",
78-
"src/favicon.ico"
90+
"src/favicon.ico",
91+
"src/assets"
7992
]
8093
}
8194
},
@@ -97,28 +110,41 @@
97110
"outputPath": "dist/server",
98111
"main": "src/main.server.ts",
99112
"tsConfig": "src/tsconfig.server.json"
113+
},
114+
"configurations": {
115+
"production": {
116+
"fileReplacements": [
117+
{
118+
"replace": "src/environments/environment.ts",
119+
"with": "src/environments/environment.prod.ts"
120+
}
121+
]
122+
}
100123
}
101124
}
102125
}
103126
},
104127
"universal-app-e2e": {
105-
"root": "e2e",
106-
"sourceRoot": "e2e",
128+
"root": "e2e/",
107129
"projectType": "application",
130+
"prefix": "",
108131
"architect": {
109132
"e2e": {
110133
"builder": "@angular-devkit/build-angular:protractor",
111134
"options": {
112-
"protractorConfig": "./protractor.conf.js",
135+
"protractorConfig": "e2e/protractor.conf.js",
113136
"devServerTarget": "universal-app:serve"
137+
},
138+
"configurations": {
139+
"production": {
140+
"devServerTarget": "universal-app:serve:production"
141+
}
114142
}
115143
},
116144
"lint": {
117145
"builder": "@angular-devkit/build-angular:tslint",
118146
"options": {
119-
"tsConfig": [
120-
"e2e/tsconfig.e2e.json"
121-
],
147+
"tsConfig": "e2e/tsconfig.e2e.json",
122148
"exclude": [
123149
"**/node_modules/**"
124150
]
@@ -127,14 +153,5 @@
127153
}
128154
}
129155
},
130-
"defaultProject": "universal-app",
131-
"schematics": {
132-
"@schematics/angular:component": {
133-
"prefix": "responsive",
134-
"styleext": "scss"
135-
},
136-
"@schematics/angular:directive": {
137-
"prefix": "responsive"
138-
}
139-
}
140-
}
156+
"defaultProject": "universal-app"
157+
}

src/apps/universal-app/protractor.conf.js renamed to src/apps/universal-app/e2e/protractor.conf.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { SpecReporter } = require('jasmine-spec-reporter');
66
exports.config = {
77
allScriptsTimeout: 11000,
88
specs: [
9-
'./e2e/**/*.e2e-spec.ts'
9+
'./src/**/*.e2e-spec.ts'
1010
],
1111
capabilities: {
1212
'browserName': 'chrome'
@@ -21,8 +21,8 @@ exports.config = {
2121
},
2222
onPrepare() {
2323
require('ts-node').register({
24-
project: 'e2e/tsconfig.e2e.json'
24+
project: require('path').join(__dirname, './tsconfig.e2e.json')
2525
});
2626
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
2727
}
28-
};
28+
};
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AppPage } from './app.po';
22

3-
describe('universal-app App', () => {
3+
describe('workspace-project App', () => {
44
let page: AppPage;
55

66
beforeEach(() => {
@@ -9,6 +9,6 @@ describe('universal-app App', () => {
99

1010
it('should display welcome message', () => {
1111
page.navigateTo();
12-
expect(page.getParagraphText()).toEqual('Welcome to responsive!');
12+
expect(page.getTitleText()).toEqual('Welcome to universal-app!');
1313
});
1414
});

src/apps/universal-app/e2e/app.po.ts renamed to src/apps/universal-app/e2e/src/app.po.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class AppPage {
55
return browser.get('/');
66
}
77

8-
getParagraphText() {
9-
return element(by.css('responsive-root h1')).getText();
8+
getTitleText() {
9+
return element(by.css('app-root h1')).getText();
1010
}
1111
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"extends": "../tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "../out-tsc/e2e",
5-
"baseUrl": "./",
4+
"outDir": "../out-tsc/app",
65
"module": "commonjs",
76
"target": "es5",
87
"types": [
@@ -11,4 +10,4 @@
1110
"node"
1211
]
1312
}
14-
}
13+
}

src/apps/universal-app/package.json

+24-23
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
{
22
"name": "universal-app",
33
"version": "0.0.0",
4-
"license": "MIT",
54
"scripts": {
65
"ng": "ng",
76
"start": "ng serve",
7+
"build": "ng build",
8+
"test": "ng test",
9+
"lint": "ng lint",
10+
"e2e": "ng e2e",
811
"start:ssr": "npm run build:ssr && node dist/server.js",
9-
"build": "ng build --prod",
1012
"build:server": "webpack --config webpack.server.config.js --progress --colors",
1113
"build:ssr": "npm run build:ssr:bundle && npm run build:server",
12-
"build:ssr:bundle": "ng build --prod && ng run universal-app:server",
13-
"test": "ng test",
14-
"lint": "ng lint",
15-
"e2e": "ng e2e"
14+
"build:ssr:bundle": "ng build --prod && ng run universal-app:server:production"
1615
},
1716
"private": true,
1817
"dependencies": {
1918
"@angular/animations": "file:../../../node_modules/@angular/animations",
2019
"@angular/cdk": "file:../../../node_modules/@angular/cdk",
21-
"@angular/cli": "^7.0.0-rc.2",
2220
"@angular/common": "file:../../../node_modules/@angular/common",
2321
"@angular/compiler": "file:../../../node_modules/@angular/compiler",
2422
"@angular/core": "file:../../../node_modules/@angular/core",
@@ -29,30 +27,33 @@
2927
"@angular/platform-browser-dynamic": "file:../../../node_modules/@angular/platform-browser-dynamic",
3028
"@angular/platform-server": "file:../../../node_modules/@angular/platform-server",
3129
"@angular/router": "file:../../../node_modules/@angular/router",
32-
"core-js": "file:../../../node_modules/core-js",
30+
"@nguniversal/express-engine": "^7.0.2",
31+
"core-js": "^2.5.4",
3332
"express": "^4.16.2",
34-
"rxjs": "file:../../../node_modules/rxjs",
35-
"zone.js": "file:../../../node_modules/zone.js"
33+
"rxjs": "~6.3.3",
34+
"tslib": "^1.9.0",
35+
"zone.js": "~0.8.26"
3636
},
3737
"devDependencies": {
38-
"@angular-devkit/build-angular": "~0.9.0-rc.1",
38+
"@angular-devkit/build-angular": "~0.11.0",
39+
"@angular/cli": "~7.1.2",
3940
"@angular/compiler-cli": "file:../../../node_modules/@angular/compiler-cli",
40-
"@angular/language-service": "^6.0.0",
41-
"@types/jasmine": "~2.8.3",
42-
"@types/jasminewd2": "~2.0.2",
43-
"@types/node": "~6.0.60",
44-
"codelyzer": "^4.0.1",
45-
"jasmine-core": "~2.8.0",
41+
"@angular/language-service": "~7.1.0",
42+
"@types/node": "~8.9.4",
43+
"@types/jasmine": "~2.8.8",
44+
"@types/jasminewd2": "~2.0.3",
45+
"codelyzer": "~4.5.0",
46+
"jasmine-core": "~2.99.1",
4647
"jasmine-spec-reporter": "~4.2.1",
47-
"karma": "~2.0.0",
48+
"karma": "~3.1.1",
4849
"karma-chrome-launcher": "~2.2.0",
49-
"karma-coverage-istanbul-reporter": "^1.2.1",
50-
"karma-jasmine": "~1.1.0",
50+
"karma-coverage-istanbul-reporter": "~2.0.1",
51+
"karma-jasmine": "~1.1.2",
5152
"karma-jasmine-html-reporter": "^0.2.2",
52-
"protractor": "~5.1.2",
53+
"protractor": "~5.4.0",
5354
"ts-loader": "^5.2.1",
54-
"ts-node": "~4.1.0",
55-
"tslint": "~5.9.1",
55+
"ts-node": "~7.0.0",
56+
"tslint": "~5.11.0",
5657
"typescript": "file:../../../node_modules/typescript",
5758
"webpack": "^4.20.2",
5859
"webpack-cli": "^3.1.2"

0 commit comments

Comments
 (0)