├── .nvmrc
├── test-app
├── src
│ ├── assets
│ │ └── .gitkeep
│ ├── main.server.ts
│ ├── environments
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── styles.css
│ ├── favicon.ico
│ ├── typings.d.ts
│ ├── tsconfig.app.json
│ ├── index.html
│ ├── tsconfig.spec.json
│ ├── tsconfig.server.json
│ ├── tslint.json
│ ├── browserslist
│ ├── main.ts
│ ├── app
│ │ ├── about
│ │ │ └── about.component.ts
│ │ ├── contact-us
│ │ │ ├── contact-us
│ │ │ │ └── contact-us.component.ts
│ │ │ ├── contact-us.module.ts
│ │ │ └── contact-us-routing.module.ts
│ │ ├── app-routing.module.ts
│ │ ├── app.module.ts
│ │ ├── app.server.module.ts
│ │ └── app.component.ts
│ ├── test.ts
│ ├── karma.conf.js
│ └── polyfills.ts
├── e2e
│ ├── src
│ │ ├── app.po.ts
│ │ └── app.e2e-spec.ts
│ └── tsconfig.e2e.json
├── tsconfig.json
├── .gitignore
├── server.ts
├── package.json
├── tslint.json
├── test.ts
└── angular.json
├── .npmignore
├── .editorconfig
├── .gitignore
├── .travis.yml
├── LICENSE
├── yarn.lock
├── appveyor.yml
├── package.json
├── index.js
└── README.md
/.nvmrc:
--------------------------------------------------------------------------------
1 | 8.11.2
2 |
--------------------------------------------------------------------------------
/test-app/src/assets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test-app/src/main.server.ts:
--------------------------------------------------------------------------------
1 | export { AppServerModule } from './app/app.server.module';
2 |
3 |
4 |
--------------------------------------------------------------------------------
/test-app/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/test-app/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | test-app
2 | .envrc
3 | .nvmrc
4 | .editorconfig
5 | yarn.lock
6 | .travis.yml
7 | appveyor.yml
8 |
--------------------------------------------------------------------------------
/test-app/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/exequiel09/fastify-angular-universal/HEAD/test-app/src/favicon.ico
--------------------------------------------------------------------------------
/test-app/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/test-app/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "es2015",
6 | "types": []
7 | },
8 | "exclude": [
9 | "src/test.ts",
10 | "**/*.spec.ts"
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/test-app/e2e/src/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test-app/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types": [
8 | "jasmine",
9 | "jasminewd2",
10 | "node"
11 | ]
12 | }
13 | }
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
15 |
16 |
--------------------------------------------------------------------------------
/test-app/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | TestApp
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/test-app/e2e/src/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 |
3 | describe('workspace-project App', () => {
4 | let page: AppPage;
5 |
6 | beforeEach(() => {
7 | page = new AppPage();
8 | });
9 |
10 | it('should display welcome message', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('Welcome to test-app!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/test-app/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "module": "commonjs",
6 | "types": [
7 | "jasmine",
8 | "node"
9 | ]
10 | },
11 | "files": [
12 | "test.ts",
13 | "polyfills.ts"
14 | ],
15 | "include": [
16 | "**/*.spec.ts",
17 | "**/*.d.ts"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/test-app/src/tsconfig.server.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "baseUrl": "./",
6 | "module": "commonjs",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts"
12 | ],
13 | "angularCompilerOptions": {
14 | "entryModule": "app/app.server.module#AppServerModule"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/test-app/src/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "app",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "app",
14 | "kebab-case"
15 | ]
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/test-app/src/browserslist:
--------------------------------------------------------------------------------
1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
2 | # For additional information regarding the format and rule options, please see:
3 | # https://github.com/browserslist/browserslist#queries
4 | # For IE 9-11 support, please uncomment the last line of the file and adjust as needed
5 | > 0.5%
6 | last 2 versions
7 | Firefox ESR
8 | not dead
9 | # IE 9-11
--------------------------------------------------------------------------------
/test-app/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule)
12 | .catch(err => console.log(err));
13 |
--------------------------------------------------------------------------------
/test-app/src/app/about/about.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, ViewEncapsulation } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-about',
5 | template: `
6 |
7 | about works!
8 |
9 | `,
10 | styles: [],
11 | encapsulation: ViewEncapsulation.None
12 | })
13 | export class AboutComponent implements OnInit {
14 |
15 | constructor() { }
16 |
17 | ngOnInit() {
18 | }
19 |
20 | }
21 |
22 |
23 |
--------------------------------------------------------------------------------
/test-app/src/app/contact-us/contact-us/contact-us.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, ViewEncapsulation } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-contact-us',
5 | template: `
6 |
7 | contact-us works!
8 |
9 | `,
10 | styles: [],
11 | encapsulation: ViewEncapsulation.None
12 | })
13 | export class ContactUsComponent implements OnInit {
14 |
15 | constructor() { }
16 |
17 | ngOnInit() {
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules
3 |
4 | # IDEs and editors
5 | /.idea
6 | .project
7 | .classpath
8 | .c9/
9 | *.launch
10 | .settings/
11 | *.sublime-workspace
12 |
13 | # IDE - VSCode
14 | .vscode/*
15 | !.vscode/settings.json
16 | !.vscode/tasks.json
17 | !.vscode/launch.json
18 | !.vscode/extensions.json
19 |
20 | # misc
21 | npm-debug.log
22 | testem.log
23 |
24 | # System Files
25 | .DS_Store
26 | Thumbs.db
27 |
28 | # Environment Files
29 | .envrc
30 |
31 |
32 |
--------------------------------------------------------------------------------
/test-app/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "baseUrl": "./",
5 | "outDir": "./dist/out-tsc",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "moduleResolution": "node",
9 | "emitDecoratorMetadata": true,
10 | "experimentalDecorators": true,
11 | "target": "es5",
12 | "typeRoots": [
13 | "node_modules/@types"
14 | ],
15 | "lib": [
16 | "es2017",
17 | "dom"
18 | ]
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/test-app/src/app/contact-us/contact-us.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 |
4 | import { ContactUsRoutingModule } from './contact-us-routing.module';
5 | import { ContactUsComponent } from './contact-us/contact-us.component';
6 |
7 | @NgModule({
8 | imports: [
9 | CommonModule,
10 | ContactUsRoutingModule
11 | ],
12 | declarations: [ContactUsComponent]
13 | })
14 | export class ContactUsModule { }
15 |
16 |
17 |
--------------------------------------------------------------------------------
/test-app/src/app/contact-us/contact-us-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 |
4 | import { ContactUsComponent } from './contact-us/contact-us.component';
5 |
6 | const routes: Routes = [
7 | {
8 | path: '',
9 | component: ContactUsComponent
10 | }
11 | ];
12 |
13 | @NgModule({
14 | imports: [RouterModule.forChild(routes)],
15 | exports: [RouterModule]
16 | })
17 | export class ContactUsRoutingModule { }
18 |
19 |
20 |
--------------------------------------------------------------------------------
/test-app/src/app/app-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 |
4 | import { AboutComponent } from './about/about.component';
5 |
6 | const routes: Routes = [
7 | {
8 | path: 'about',
9 | component: AboutComponent
10 | },
11 |
12 | {
13 | path: 'contact-us',
14 | loadChildren: './contact-us/contact-us.module#ContactUsModule',
15 | }
16 | ];
17 |
18 | @NgModule({
19 | imports: [RouterModule.forRoot(routes)],
20 | exports: [RouterModule]
21 | })
22 | export class AppRoutingModule { }
23 |
24 |
25 |
--------------------------------------------------------------------------------
/test-app/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 |
4 | import { AppRoutingModule } from './app-routing.module';
5 | import { AppComponent } from './app.component';
6 | import { AboutComponent } from './about/about.component';
7 |
8 | @NgModule({
9 | declarations: [
10 | AppComponent,
11 | AboutComponent
12 | ],
13 | imports: [
14 | BrowserModule.withServerTransition({ appId: 'my-app' }),
15 | AppRoutingModule
16 | ],
17 | providers: [],
18 | bootstrap: [AppComponent]
19 | })
20 | export class AppModule { }
21 |
22 |
23 |
--------------------------------------------------------------------------------
/test-app/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false
7 | };
8 |
9 | /*
10 | * In development mode, to ignore zone related error stack frames such as
11 | * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can
12 | * import the following file, but please comment it out in production mode
13 | * because it will have performance impact when throw error
14 | */
15 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
16 |
--------------------------------------------------------------------------------
/test-app/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone-testing';
4 | import { getTestBed } from '@angular/core/testing';
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting
8 | } from '@angular/platform-browser-dynamic/testing';
9 |
10 | declare const require: any;
11 |
12 | // First, initialize the Angular testing environment.
13 | getTestBed().initTestEnvironment(
14 | BrowserDynamicTestingModule,
15 | platformBrowserDynamicTesting()
16 | );
17 | // Then we find all the tests.
18 | const context = require.context('./', true, /\.spec\.ts$/);
19 | // And load the modules.
20 | context.keys().map(context);
21 |
--------------------------------------------------------------------------------
/test-app/.gitignore:
--------------------------------------------------------------------------------
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 | # IDEs and editors
12 | /.idea
13 | .project
14 | .classpath
15 | .c9/
16 | *.launch
17 | .settings/
18 | *.sublime-workspace
19 |
20 | # IDE - VSCode
21 | .vscode/*
22 | !.vscode/settings.json
23 | !.vscode/tasks.json
24 | !.vscode/launch.json
25 | !.vscode/extensions.json
26 |
27 | # misc
28 | /.sass-cache
29 | /connect.lock
30 | /coverage
31 | /libpeerconnection.log
32 | npm-debug.log
33 | yarn-error.log
34 | testem.log
35 | /typings
36 |
37 | # e2e
38 | /e2e/*.js
39 | /e2e/*.map
40 |
41 | # System Files
42 | .DS_Store
43 | Thumbs.db
44 |
45 | # Environment Files
46 | .envrc
47 |
48 |
49 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | sudo: true
3 |
4 | dist: trusty
5 |
6 | node_js:
7 | - "8"
8 |
9 | notifications:
10 | email:
11 | on_success: never
12 | on_failure: always
13 |
14 | env:
15 | global:
16 | - YARN_VERSION: 1.7.0
17 | - NG_CLI_VERSION: 6.0.8
18 |
19 | before_install:
20 | # Install latest yarn
21 | - curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version $YARN_VERSION
22 | - export PATH="$HOME/.yarn/bin:$PATH"
23 |
24 | # Install @angular/cli
25 | - npm install -g @angular/cli@$NG_CLI_VERSION
26 |
27 | # install the dependencies and build the necessary files
28 | - cd test-app && yarn install && yarn build:browser && yarn build:server
29 |
30 | script:
31 | # run the test script in the directory
32 | - cd ../test-app && yarn test
33 |
34 |
35 |
--------------------------------------------------------------------------------
/test-app/src/app/app.server.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { ServerModule } from '@angular/platform-server';
3 | import { ModuleMapLoaderModule } from '@nguniversal/module-map-ngfactory-loader';
4 |
5 | import { AppModule } from './app.module';
6 | import { AppComponent } from './app.component';
7 |
8 | @NgModule({
9 | imports: [
10 | // The AppServerModule should import your AppModule followed
11 | // by the ServerModule from @angular/platform-server.
12 | AppModule,
13 | ServerModule,
14 | ModuleMapLoaderModule // <-- *Important* to have lazy-loaded routes work
15 | ],
16 | // Since the bootstrapped component is not inherited from your
17 | // imported AppModule, it needs to be repeated here.
18 | bootstrap: [AppComponent],
19 | })
20 | export class AppServerModule { }
21 |
22 |
23 |
--------------------------------------------------------------------------------
/test-app/src/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, '../coverage'),
20 | reports: ['html', 'lcovonly'],
21 | fixWebpackSourcePaths: true
22 | },
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false
30 | });
31 | };
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Exequiel Ceasar Navarrete
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/yarn.lock:
--------------------------------------------------------------------------------
1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2 | # yarn lockfile v1
3 |
4 |
5 | "@angular/platform-server@^6.0.4":
6 | version "6.0.4"
7 | resolved "https://registry.yarnpkg.com/@angular/platform-server/-/platform-server-6.0.4.tgz#38de69d98ca01a4e20d6eac7d19b85d9257f06aa"
8 | dependencies:
9 | domino "^2.0.1"
10 | tslib "^1.9.0"
11 | xhr2 "^0.1.4"
12 |
13 | domino@^2.0.1:
14 | version "2.0.2"
15 | resolved "https://registry.yarnpkg.com/domino/-/domino-2.0.2.tgz#fa2da6ace8381cf64089079470ee33c53901010f"
16 |
17 | fastify-plugin@^1.0.1:
18 | version "1.0.1"
19 | resolved "https://registry.yarnpkg.com/fastify-plugin/-/fastify-plugin-1.0.1.tgz#4bd94d6f27cddf59fd43e188d6eedb1168ffc35d"
20 | dependencies:
21 | semver "^5.5.0"
22 |
23 | semver@^5.5.0:
24 | version "5.5.0"
25 | resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"
26 |
27 | tslib@^1.9.0:
28 | version "1.9.2"
29 | resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.2.tgz#8be0cc9a1f6dc7727c38deb16c2ebd1a2892988e"
30 |
31 | xhr2@^0.1.4:
32 | version "0.1.4"
33 | resolved "https://registry.yarnpkg.com/xhr2/-/xhr2-0.1.4.tgz#7f87658847716db5026323812f818cadab387a5f"
34 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | # Test against this version of Node.js
2 | environment:
3 | matrix:
4 | - nodejs_version: '8'
5 |
6 | # fail all the builds once any of the builds fail have failed
7 | matrix:
8 | fast_finish: true
9 |
10 | # build only this branches
11 | branches:
12 | only:
13 | - master
14 |
15 | # Do not build tags
16 | skip_tags: true
17 |
18 | # Pull Requests do not increment build number
19 | pull_requests:
20 | do_not_increment_build_number: true
21 |
22 | # Install scripts. (runs after repo cloning)
23 | install:
24 | # install google chrome
25 | - choco install googlechrome
26 |
27 | # Get the latest stable version of Node.js or io.js
28 | - ps: Install-Product node $env:nodejs_version
29 |
30 | # Install @angular/cli globally
31 | - npm install -g @angular/cli@6.0.8
32 |
33 | # install the dependencies and build the necessary files
34 | - cd test-app && yarn install && yarn build:browser && yarn build:server
35 |
36 | # Post-install test scripts.
37 | test_script:
38 | # Output useful info for debugging.
39 | - node --version
40 | - npm --version
41 |
42 | # run the test script in the directory
43 | - set NODE_ENV=production
44 | - cd test-app && ng --version && yarn test:win
45 |
46 | # Don't actually build.
47 | build: off
48 |
49 |
50 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fastify-angular-universal",
3 | "version": "0.4.0",
4 | "author": "Exequiel Ceasar Navarrete",
5 | "description": "Fastify plugin for rendering an Angular app from the server using Angular Universal",
6 | "main": "index.js",
7 | "keywords": [
8 | "fastify",
9 | "angular",
10 | "angular-universal",
11 | "server-side-rendering"
12 | ],
13 | "repository": {
14 | "type": "git",
15 | "url": "https://github.com/exequiel09/fastify-angular-universal.git"
16 | },
17 | "bugs": {
18 | "url": "https://github.com/exequiel09/fastify-angular-universal/issues"
19 | },
20 | "license": "MIT",
21 | "dependencies": {
22 | "@angular/platform-server": "^6.0.4",
23 | "fastify-plugin": "^1.0.1"
24 | },
25 | "peerDependencies": {
26 | "@angular/animations": "^6.0.4",
27 | "@angular/common": "^6.0.4",
28 | "@angular/compiler": "^6.0.4",
29 | "@angular/core": "^6.0.4",
30 | "@angular/forms": "^6.0.4",
31 | "@angular/http": "^6.0.4",
32 | "@angular/platform-browser": "^6.0.4",
33 | "@angular/platform-browser-dynamic": "^6.0.4",
34 | "@angular/router": "^6.0.4",
35 | "fastify": "^1.5.0",
36 | "rxjs": "^6.2.0"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/test-app/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | template: `
6 |
7 |
8 |
9 | Welcome to {{title}}!
10 |
11 |

12 |
13 | Here are some links to help you start:
14 |
15 | -
16 |
17 |
18 | -
19 |
20 |
21 | -
22 |
23 |
24 |
25 |
26 | `,
27 | styles: []
28 | })
29 | export class AppComponent {
30 | title = 'app';
31 | }
32 |
--------------------------------------------------------------------------------
/test-app/server.ts:
--------------------------------------------------------------------------------
1 | // These are important and needed before anything else
2 | import 'zone.js/dist/zone-node';
3 | import 'reflect-metadata';
4 |
5 | import { join } from 'path';
6 | import { readFileSync } from 'fs';
7 |
8 | import { enableProdMode } from '@angular/core';
9 | import * as fastify from 'fastify';
10 |
11 | // * NOTE :: leave this as require() since this file is built Dynamically from webpack
12 | const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/test-app-server/main');
13 | const { provideModuleMap } = require('@nguniversal/module-map-ngfactory-loader');
14 |
15 | // Faster server renders w/ Prod mode (dev mode never needed)
16 | enableProdMode();
17 |
18 | const PORT = process.env.PORT || 3000;
19 | const DIST_FOLDER = join(process.cwd(), 'dist');
20 |
21 | // Our index.html we'll use as our template
22 | const template = readFileSync(join(DIST_FOLDER, 'test-app', 'index.html')).toString();
23 |
24 | const app = fastify();
25 |
26 | app.register(require('fastify-static'), {
27 | root: join(DIST_FOLDER, 'test-app'),
28 | prefix: '/static/'
29 | });
30 |
31 | // register the fastify-angular-universal to your application together with the required options
32 | app.register(require('fastify-angular-universal'), {
33 | serverModule: AppServerModuleNgFactory,
34 | document: template,
35 | extraProviders: [
36 | provideModuleMap(LAZY_MODULE_MAP)
37 | ]
38 | });
39 |
40 | // Declare a route
41 | app.get('/*', function (request, reply) {
42 | (reply as any).renderNg(request.req.url);
43 | });
44 |
45 | // Run the server!
46 | app.listen(parseInt(PORT + '', 10), function (err) {
47 | if (err) {
48 | throw err;
49 | }
50 |
51 | console.log(`server listening on ${app.server.address().port}`);
52 | });
53 |
54 |
55 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const fastifyPlugin = require('fastify-plugin');
4 | const { renderModuleFactory } = require('@angular/platform-server');
5 |
6 | function fastifyNgUniversal(fastify, opts, next) {
7 |
8 | // set default value for the fastify plugin extraProviders option
9 | opts.extraProviders = opts.extraProviders || [];
10 |
11 | // add a reply decorator
12 | fastify.decorateReply('renderNg', function (url, options = {}) {
13 | const serverModule = options.serverModule || opts.serverModule;
14 | const documentTemplate = options.document || opts.document;
15 | let extraProviders = [];
16 |
17 | // set default value for the reply decorator extraProviders option
18 | options.extraProviders = options.extraProviders || [];
19 |
20 | // append custom extra providers if there is any
21 | extraProviders = extraProviders.concat(opts.extraProviders, options.extraProviders);
22 |
23 | // check if the server module has value or not
24 | if (!serverModule) {
25 | this.send(new Error('Missing Angular Server module to render.'));
26 | return;
27 | }
28 |
29 | // check if the document template has value or not
30 | if (!documentTemplate) {
31 | this.send(new Error('Missing template where the Angular app will be rendered.'));
32 | return;
33 | }
34 |
35 | // assemble the options
36 | const renderOpts = {
37 | document: documentTemplate,
38 | url: url,
39 | extraProviders
40 | };
41 |
42 | // render the angular application
43 | renderModuleFactory(serverModule, renderOpts)
44 | .then(html => {
45 | this.header('Content-Type', 'text/html').send(html);
46 | })
47 | ;
48 | });
49 |
50 | next();
51 | }
52 |
53 | module.exports = fastifyPlugin(fastifyNgUniversal, '>=1.5.0');
54 |
55 |
56 |
--------------------------------------------------------------------------------
/test-app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "test-app",
3 | "version": "0.1.0",
4 | "author": "Exequiel Ceasar Navarrete",
5 | "description": "Test Angular app for validating if the fastify-angular-universal plugin works",
6 | "license": "MIT",
7 | "scripts": {
8 | "ng": "ng",
9 | "start": "ng serve",
10 | "start:ssr": "ts-node server.ts",
11 | "build": "ng build",
12 | "build:browser": "ng build --prod --deploy-url /static/",
13 | "build:server": "ng run test-app:server",
14 | "test": "NODE_ENV=production ts-node test.ts",
15 | "test:win": "ts-node test.ts",
16 | "lint": "ng lint",
17 | "e2e": "ng e2e"
18 | },
19 | "private": true,
20 | "dependencies": {
21 | "@angular/animations": "^6.0.4",
22 | "@angular/common": "^6.0.4",
23 | "@angular/compiler": "^6.0.4",
24 | "@angular/core": "^6.0.4",
25 | "@angular/forms": "^6.0.4",
26 | "@angular/http": "^6.0.4",
27 | "@angular/platform-browser": "^6.0.4",
28 | "@angular/platform-browser-dynamic": "^6.0.4",
29 | "@angular/platform-server": "^6.0.4",
30 | "@angular/router": "^6.0.4",
31 | "@nguniversal/module-map-ngfactory-loader": "^6.0.0",
32 | "core-js": "^2.5.4",
33 | "fastify": "^1.5.0",
34 | "fastify-angular-universal": "file:../",
35 | "fastify-static": "^0.12.0",
36 | "rxjs": "^6.0.0",
37 | "ts-loader": "^4.4.1",
38 | "zone.js": "^0.8.26"
39 | },
40 | "devDependencies": {
41 | "@angular-devkit/build-angular": "~0.6.8",
42 | "@angular/cli": "~6.0.8",
43 | "@angular/compiler-cli": "^6.0.4",
44 | "@angular/language-service": "^6.0.4",
45 | "@types/jasmine": "~2.8.6",
46 | "@types/jasminewd2": "~2.0.3",
47 | "@types/node": "~8.9.4",
48 | "codelyzer": "~4.2.1",
49 | "jasmine-core": "~2.99.1",
50 | "jasmine-spec-reporter": "~4.2.1",
51 | "karma": "~1.7.1",
52 | "karma-chrome-launcher": "~2.2.0",
53 | "karma-coverage-istanbul-reporter": "~2.0.0",
54 | "karma-jasmine": "~1.1.1",
55 | "karma-jasmine-html-reporter": "^0.2.2",
56 | "protractor": "~5.3.2",
57 | "tap": "^12.0.1",
58 | "ts-node": "~5.0.1",
59 | "tslint": "~5.9.1",
60 | "typescript": "~2.7.2"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/test-app/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "arrow-return-shorthand": true,
7 | "callable-types": true,
8 | "class-name": true,
9 | "comment-format": [
10 | true,
11 | "check-space"
12 | ],
13 | "curly": true,
14 | "deprecation": {
15 | "severity": "warn"
16 | },
17 | "eofline": true,
18 | "forin": true,
19 | "import-blacklist": [
20 | true,
21 | "rxjs/Rx"
22 | ],
23 | "import-spacing": true,
24 | "indent": [
25 | true,
26 | "spaces"
27 | ],
28 | "interface-over-type-literal": true,
29 | "label-position": true,
30 | "max-line-length": [
31 | true,
32 | 140
33 | ],
34 | "member-access": false,
35 | "member-ordering": [
36 | true,
37 | {
38 | "order": [
39 | "static-field",
40 | "instance-field",
41 | "static-method",
42 | "instance-method"
43 | ]
44 | }
45 | ],
46 | "no-arg": true,
47 | "no-bitwise": true,
48 | "no-console": [
49 | true,
50 | "debug",
51 | "info",
52 | "time",
53 | "timeEnd",
54 | "trace"
55 | ],
56 | "no-construct": true,
57 | "no-debugger": true,
58 | "no-duplicate-super": true,
59 | "no-empty": false,
60 | "no-empty-interface": true,
61 | "no-eval": true,
62 | "no-inferrable-types": [
63 | true,
64 | "ignore-params"
65 | ],
66 | "no-misused-new": true,
67 | "no-non-null-assertion": true,
68 | "no-shadowed-variable": true,
69 | "no-string-literal": false,
70 | "no-string-throw": true,
71 | "no-switch-case-fall-through": true,
72 | "no-trailing-whitespace": true,
73 | "no-unnecessary-initializer": true,
74 | "no-unused-expression": true,
75 | "no-use-before-declare": true,
76 | "no-var-keyword": true,
77 | "object-literal-sort-keys": false,
78 | "one-line": [
79 | true,
80 | "check-open-brace",
81 | "check-catch",
82 | "check-else",
83 | "check-whitespace"
84 | ],
85 | "prefer-const": true,
86 | "quotemark": [
87 | true,
88 | "single"
89 | ],
90 | "radix": true,
91 | "semicolon": [
92 | true,
93 | "always"
94 | ],
95 | "triple-equals": [
96 | true,
97 | "allow-null-check"
98 | ],
99 | "typedef-whitespace": [
100 | true,
101 | {
102 | "call-signature": "nospace",
103 | "index-signature": "nospace",
104 | "parameter": "nospace",
105 | "property-declaration": "nospace",
106 | "variable-declaration": "nospace"
107 | }
108 | ],
109 | "unified-signatures": true,
110 | "variable-name": false,
111 | "whitespace": [
112 | true,
113 | "check-branch",
114 | "check-decl",
115 | "check-operator",
116 | "check-separator",
117 | "check-type"
118 | ],
119 | "no-output-on-prefix": true,
120 | "use-input-property-decorator": true,
121 | "use-output-property-decorator": true,
122 | "use-host-property-decorator": true,
123 | "no-input-rename": true,
124 | "no-output-rename": true,
125 | "use-life-cycle-interface": true,
126 | "use-pipe-transform-interface": true,
127 | "component-class-suffix": true,
128 | "directive-class-suffix": true
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/test-app/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/
22 | // import 'core-js/es6/symbol';
23 | // import 'core-js/es6/object';
24 | // import 'core-js/es6/function';
25 | // import 'core-js/es6/parse-int';
26 | // import 'core-js/es6/parse-float';
27 | // import 'core-js/es6/number';
28 | // import 'core-js/es6/math';
29 | // import 'core-js/es6/string';
30 | // import 'core-js/es6/date';
31 | // import 'core-js/es6/array';
32 | // import 'core-js/es6/regexp';
33 | // import 'core-js/es6/map';
34 | // import 'core-js/es6/weak-map';
35 | // import 'core-js/es6/set';
36 |
37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
38 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
39 |
40 | /** IE10 and IE11 requires the following for the Reflect API. */
41 | // import 'core-js/es6/reflect';
42 |
43 |
44 | /** Evergreen browsers require these. **/
45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
46 | import 'core-js/es7/reflect';
47 |
48 |
49 | /**
50 | * Web Animations `@angular/platform-browser/animations`
51 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
52 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
53 | **/
54 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
55 |
56 | /**
57 | * By default, zone.js will patch all possible macroTask and DomEvents
58 | * user can disable parts of macroTask/DomEvents patch by setting following flags
59 | */
60 |
61 | // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
62 | // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
63 | // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
64 |
65 | /*
66 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
67 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
68 | */
69 | // (window as any).__Zone_enable_cross_context_check = true;
70 |
71 | /***************************************************************************************************
72 | * Zone JS is required by default for Angular itself.
73 | */
74 | import 'zone.js/dist/zone'; // Included with Angular CLI.
75 |
76 |
77 |
78 | /***************************************************************************************************
79 | * APPLICATION IMPORTS
80 | */
81 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # fastify-angular-universal
2 |
3 | [![Master - Build Status][img-travis-master]][link-travis]
4 | [![Master - Build Status][img-appveyor-master]][link-appveyor-master]
5 | [![LICENSE][img-license]][link-license]
6 |
7 | Angular server-side rendering support for Fastify using Angular Universal.
8 |
9 | ## Install
10 |
11 | ``
12 | npm install --save fastify-angular-universal
13 | ``
14 |
15 | ## Usage
16 |
17 | Add it to you project with `register` and pass the required options.
18 |
19 | Follow the tutorial on how to perform SSR in Angular with Angular CLI [here][link-angular-cli-universal-rendering] ONLY UNTIL step 3.
20 |
21 | For the steps 4 and onwards use the following `server.ts` or check out the [`server.ts`][link-server-ts] in the test-app directory
22 |
23 | ```typescript
24 | // These are important and needed before anything else
25 | import 'zone.js/dist/zone-node';
26 | import 'reflect-metadata';
27 |
28 | import { join } from 'path';
29 | import { readFileSync } from 'fs';
30 |
31 | import { enableProdMode } from '@angular/core';
32 | import * as fastify from 'fastify';
33 |
34 | // * NOTE :: leave this as require() since this file is built Dynamically from webpack
35 | const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/-server/main');
36 | const { provideModuleMap } = require('@nguniversal/module-map-ngfactory-loader');
37 |
38 | // Faster server renders w/ Prod mode (dev mode never needed)
39 | enableProdMode();
40 |
41 | const PORT = process.env.PORT || 3000;
42 | const DIST_FOLDER = join(process.cwd(), 'dist');
43 |
44 | // Our index.html we'll use as our template
45 | const template = readFileSync(join(DIST_FOLDER, '', 'index.html')).toString();
46 |
47 | const app = fastify();
48 |
49 | app.register(require('fastify-static'), {
50 | root: join(DIST_FOLDER, ''),
51 | prefix: '/static/'
52 | });
53 |
54 | // register the fastify-angular-universal to your application together with the required options
55 | app.register(require('fastify-angular-universal'), {
56 | serverModule: AppServerModuleNgFactory,
57 | document: template,
58 | extraProviders: [
59 | provideModuleMap(LAZY_MODULE_MAP)
60 | ]
61 | });
62 |
63 | // Declare a route
64 | app.get('/*', function (request, reply) {
65 | // NOTE: you can also pass the options for the fastify-angular-universal fastify plugin
66 | // as second parameter to the `.renderNg()` function.
67 | //
68 | // Example: `reply.renderNg(url, options)`
69 | (reply as any).renderNg(request.req.url);
70 | });
71 |
72 | // Run the server!
73 | app.listen(PORT, function (err) {
74 | if (err) {
75 | throw err;
76 | }
77 |
78 | console.log(`server listening on ${app.server.address().port}`);
79 | });
80 | ```
81 |
82 | ## Options
83 |
84 | This plugin allow you to specify options:
85 |
86 | - `serverModule` to specify the NgModuleFactory to be used in rendering an Angular app in the server
87 | - `document` to specify the template where the Angular app will be rendered
88 | - `extraProviders` to specify additional providers to be used by the Angular app. (optional)
89 |
90 | ## License
91 |
92 | [MIT][link-license].
93 |
94 |
95 | [img-travis-master]: https://travis-ci.org/exequiel09/fastify-angular-universal.svg?branch=master
96 | [img-appveyor-master]: https://ci.appveyor.com/api/projects/status/5hg5qsav8q2xjqah/branch/master?svg=true
97 | [img-license]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
98 |
99 |
100 |
101 |
102 | [link-license]: ./LICENSE
103 | [link-travis]: https://travis-ci.org/exequiel09/fastify-angular-universal
104 | [link-appveyor-master]: https://ci.appveyor.com/project/exequiel09/fastify-angular-universal/branch/master
105 | [link-angular-cli-universal-rendering]: https://github.com/angular/angular-cli/wiki/stories-universal-rendering
106 | [link-server-ts]: https://github.com/exequiel09/fastify-angular-universal/blob/master/test-app/server.ts
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/test-app/test.ts:
--------------------------------------------------------------------------------
1 | // These are important and needed before anything else
2 | import 'zone.js/dist/zone-node';
3 | import 'reflect-metadata';
4 |
5 | import { join } from 'path';
6 | import { readFileSync } from 'fs';
7 |
8 | import { enableProdMode } from '@angular/core';
9 | import * as Fastify from 'fastify';
10 |
11 | // Faster server renders w/ Prod mode (dev mode never needed)
12 | enableProdMode();
13 |
14 | const t = require('tap');
15 | const test = t.test;
16 |
17 | const DIST_FOLDER = join(process.cwd(), 'dist');
18 |
19 | const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/test-app-server/main');
20 | const { provideModuleMap } = require('@nguniversal/module-map-ngfactory-loader');
21 | const template = readFileSync(join(DIST_FOLDER, 'test-app', 'index.html')).toString();
22 |
23 | test('should return an html document', childTest => {
24 | childTest.plan(6);
25 |
26 | const fastify = Fastify();
27 |
28 | // just for the sake of preventing errors associated with static assets like css and js
29 | fastify.register(require('fastify-static'), {
30 | root: join(DIST_FOLDER, 'test-app'),
31 | prefix: '/static/'
32 | });
33 |
34 | fastify.register(require('fastify-angular-universal'), {
35 | serverModule: AppServerModuleNgFactory,
36 | document: template,
37 | extraProviders: [
38 | provideModuleMap(LAZY_MODULE_MAP)
39 | ]
40 | });
41 |
42 | // Declare a route
43 | fastify.get('/*', function (request, reply) {
44 | (reply as any).renderNg(request.req.url);
45 | });
46 |
47 | // retrieve the homepage
48 | fastify.inject({
49 | url: '/',
50 | method: 'GET'
51 | }, (err, res) => {
52 | childTest.equal(res.statusCode, 200);
53 | childTest.equal(res.headers['content-type'], 'text/html');
54 | });
55 |
56 | // retrieve the about page
57 | fastify.inject({
58 | url: '/about',
59 | method: 'GET'
60 | }, (err, res) => {
61 | childTest.equal(res.statusCode, 200);
62 | childTest.equal(res.headers['content-type'], 'text/html');
63 | });
64 |
65 | // retrieve the contact-us page
66 | fastify.inject({
67 | url: '/contact-us',
68 | method: 'GET'
69 | }, (err, res) => {
70 | childTest.equal(res.statusCode, 200);
71 | childTest.equal(res.headers['content-type'], 'text/html');
72 | });
73 | });
74 |
75 | test('should throw if serverModule option is not provided', childTest => {
76 | childTest.plan(3);
77 |
78 | const fastify = Fastify();
79 |
80 | // just for the sake of preventing errors associated with static assets like css and js
81 | fastify.register(require('fastify-static'), {
82 | root: join(DIST_FOLDER, 'test-app'),
83 | prefix: '/static/'
84 | });
85 |
86 | fastify.register(require('fastify-angular-universal'), {
87 | document: template,
88 | extraProviders: [
89 | provideModuleMap(LAZY_MODULE_MAP)
90 | ]
91 | });
92 |
93 | // Declare a route
94 | fastify.get('/*', function (request, reply) {
95 | (reply as any).renderNg(request.req.url);
96 | });
97 |
98 | fastify.inject({
99 | url: '/',
100 | method: 'GET'
101 | }, (err, res) => {
102 | const payload = JSON.parse(res.payload);
103 |
104 | childTest.equal(res.statusCode, 500);
105 | childTest.equal(res.statusMessage, 'Internal Server Error');
106 | childTest.equal(payload.message, 'Missing Angular Server module to render.');
107 | });
108 | });
109 |
110 | test('should throw if document option is not provided', childTest => {
111 | childTest.plan(3);
112 |
113 | const fastify = Fastify();
114 |
115 | // just for the sake of preventing errors associated with static assets like css and js
116 | fastify.register(require('fastify-static'), {
117 | root: join(DIST_FOLDER, 'test-app'),
118 | prefix: '/static/'
119 | });
120 |
121 | fastify.register(require('fastify-angular-universal'), {
122 | serverModule: AppServerModuleNgFactory,
123 | extraProviders: [
124 | provideModuleMap(LAZY_MODULE_MAP)
125 | ]
126 | });
127 |
128 | // Declare a route
129 | fastify.get('/*', function (request, reply) {
130 | (reply as any).renderNg(request.req.url);
131 | });
132 |
133 | fastify.inject({
134 | url: '/',
135 | method: 'GET'
136 | }, (err, res) => {
137 | const payload = JSON.parse(res.payload);
138 |
139 | childTest.equal(res.statusCode, 500);
140 | childTest.equal(res.statusMessage, 'Internal Server Error');
141 | childTest.equal(payload.message, 'Missing template where the Angular app will be rendered.');
142 | });
143 | });
144 |
145 |
146 |
--------------------------------------------------------------------------------
/test-app/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "test-app": {
7 | "root": "",
8 | "sourceRoot": "src",
9 | "projectType": "application",
10 | "prefix": "app",
11 | "schematics": {
12 | "@schematics/angular:component": {
13 | "inlineTemplate": true,
14 | "inlineStyle": true,
15 | "spec": false
16 | },
17 | "@schematics/angular:class": {
18 | "spec": false
19 | },
20 | "@schematics/angular:directive": {
21 | "spec": false
22 | },
23 | "@schematics/angular:guard": {
24 | "spec": false
25 | },
26 | "@schematics/angular:module": {
27 | "spec": false
28 | },
29 | "@schematics/angular:pipe": {
30 | "spec": false
31 | },
32 | "@schematics/angular:service": {
33 | "spec": false
34 | }
35 | },
36 | "architect": {
37 | "build": {
38 | "builder": "@angular-devkit/build-angular:browser",
39 | "options": {
40 | "outputPath": "dist/test-app",
41 | "index": "src/index.html",
42 | "main": "src/main.ts",
43 | "polyfills": "src/polyfills.ts",
44 | "tsConfig": "src/tsconfig.app.json",
45 | "assets": [
46 | "src/favicon.ico",
47 | "src/assets"
48 | ],
49 | "styles": [
50 | "src/styles.css"
51 | ],
52 | "scripts": []
53 | },
54 | "configurations": {
55 | "production": {
56 | "fileReplacements": [
57 | {
58 | "replace": "src/environments/environment.ts",
59 | "with": "src/environments/environment.prod.ts"
60 | }
61 | ],
62 | "optimization": true,
63 | "outputHashing": "all",
64 | "sourceMap": false,
65 | "extractCss": true,
66 | "namedChunks": false,
67 | "aot": true,
68 | "extractLicenses": true,
69 | "vendorChunk": false,
70 | "buildOptimizer": true
71 | }
72 | }
73 | },
74 | "server": {
75 | "builder": "@angular-devkit/build-angular:server",
76 | "options": {
77 | "outputPath": "dist/test-app-server",
78 | "main": "src/main.server.ts",
79 | "tsConfig": "src/tsconfig.server.json"
80 | }
81 | },
82 | "serve": {
83 | "builder": "@angular-devkit/build-angular:dev-server",
84 | "options": {
85 | "browserTarget": "test-app:build"
86 | },
87 | "configurations": {
88 | "production": {
89 | "browserTarget": "test-app:build:production"
90 | }
91 | }
92 | },
93 | "extract-i18n": {
94 | "builder": "@angular-devkit/build-angular:extract-i18n",
95 | "options": {
96 | "browserTarget": "test-app:build"
97 | }
98 | },
99 | "test": {
100 | "builder": "@angular-devkit/build-angular:karma",
101 | "options": {
102 | "main": "src/test.ts",
103 | "polyfills": "src/polyfills.ts",
104 | "tsConfig": "src/tsconfig.spec.json",
105 | "karmaConfig": "src/karma.conf.js",
106 | "styles": [
107 | "src/styles.css"
108 | ],
109 | "scripts": [],
110 | "assets": [
111 | "src/favicon.ico",
112 | "src/assets"
113 | ]
114 | }
115 | },
116 | "lint": {
117 | "builder": "@angular-devkit/build-angular:tslint",
118 | "options": {
119 | "tsConfig": [
120 | "src/tsconfig.app.json",
121 | "src/tsconfig.spec.json"
122 | ],
123 | "exclude": [
124 | "**/node_modules/**"
125 | ]
126 | }
127 | }
128 | }
129 | },
130 | "test-app-e2e": {
131 | "root": "e2e/",
132 | "projectType": "application",
133 | "architect": {
134 | "e2e": {
135 | "builder": "@angular-devkit/build-angular:protractor",
136 | "options": {
137 | "protractorConfig": "e2e/protractor.conf.js",
138 | "devServerTarget": "test-app:serve"
139 | },
140 | "configurations": {
141 | "production": {
142 | "devServerTarget": "test-app:serve:production"
143 | }
144 | }
145 | },
146 | "lint": {
147 | "builder": "@angular-devkit/build-angular:tslint",
148 | "options": {
149 | "tsConfig": "e2e/tsconfig.e2e.json",
150 | "exclude": [
151 | "**/node_modules/**"
152 | ]
153 | }
154 | }
155 | }
156 | }
157 | },
158 | "defaultProject": "test-app"
159 | }
160 |
--------------------------------------------------------------------------------