├── .editorconfig ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── Procfile ├── README.md ├── angular.json ├── commitlint.config.js ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.e2e.json ├── local.js ├── ng-toolkit.json ├── ngsw-config.json ├── package.json ├── renovate.json ├── server.ts ├── src ├── app │ ├── app-routing.module.ts │ ├── app.browser.module.ts │ ├── app.component.html │ ├── app.component.scss │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── app.server.module.ts │ └── not-found │ │ ├── not-found.component.html │ │ ├── not-found.component.scss │ │ ├── not-found.component.spec.ts │ │ └── not-found.component.ts ├── assets │ ├── .gitkeep │ └── icons │ │ ├── icon-128x128.png │ │ ├── icon-144x144.png │ │ ├── icon-152x152.png │ │ ├── icon-192x192.png │ │ ├── icon-384x384.png │ │ ├── icon-512x512.png │ │ ├── icon-72x72.png │ │ └── icon-96x96.png ├── browserslist ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── karma.conf.js ├── main.server.ts ├── main.ts ├── manifest.json ├── polyfills.ts ├── styles.scss ├── test.ts ├── tsconfig.app.json ├── tsconfig.server.json ├── tsconfig.spec.json └── tslint.json ├── tsconfig.json ├── tslint.json ├── webpack.server.config.js └── yarn.lock /.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 | -------------------------------------------------------------------------------- /.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 | # System Files 38 | .DS_Store 39 | Thumbs.db 40 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution 2 | It would be awesome if you to contributed to this angular universal starter repo and help make it even better than it is today! As a contributor, there are some guidelines to follow 3 | 4 | ## Found a bug? 5 | If you find a bug, you can help by submitting an issue. Even better, you can submit a Pull Request with a fix. 6 | 7 | ## Missing a Feature? 8 | You can request a new feature by submitting an issue. If you would like to implement a new feature, Feel free to fork this repo and create a pull request. Make sure you give details about the feature you are implementing. 9 | 10 | ## Commit Message Guidelines 11 | This repo follows the commit message guidelines specified in the [official angular contribution docs](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#rules). This repo has git-hooks that check linting and make sure you have followed the angular commit guidlines before you an push. 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Alex Ginns 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 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: npm run start:heroku -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

🔥 Angular 8 PWA Universal Heroku Starter 🔥

2 |

3 | 4 | 5 | 6 | 7 | 8 |

9 |

10 | 11 |

12 | 13 | **DEMO SITE** 14 | https://angular-heroku-starter.herokuapp.com/ 15 | 16 | **This is a starting point for an Angular Universal application that can then be published correctly to heroku with working SSR(server side rendering)** 17 | 18 | This starter was created by creating a new angular application with `@angular/cli@8.2.9` and combining the techniques shown in these two articles. [deploying-an-angular-universal-app-to-heroku](https://medium.com/augie-gardner/deploying-an-angular-universal-app-to-heroku-eca2b7966947) and [enable-angular-universal-for-existing-app](https://medium.com/@mafshin/enable-angular-universal-for-existing-app-3a17694b9177) plus some additional configuration to get it all working on Angular 8 19 | 20 | *If you're looking for the Angular Universal repo go to [angular/universal](https://github.com/angular/universal) 21 | 22 | **Table of contents** 23 | * [Getting Started](https://github.com/Alex61NN5/angular-universal-heroku-starter#getting-started) 24 | * [Development](https://github.com/Alex61NN5/angular-universal-heroku-starter#getting-started) 25 | * [Heroku](https://github.com/Alex61NN5/angular-universal-heroku-starter#getting-started) 26 | * [PWA](https://github.com/Alex61NN5/angular-universal-heroku-starter#getting-started) 27 | * [Universal Gotcha's](https://github.com/Alex61NN5/angular-universal-heroku-starter#universal-gotchas) 28 | * [Contribution Guidelines](https://github.com/Alex61NN5/angular-universal-heroku-starter/blob/master/CONTRIBUTING.md) 29 | * [Lincence](https://github.com/Alex61NN5/angular-universal-heroku-starter/blob/master/LICENSE) 30 | 31 | ## Getting Started 32 | 33 | Download the project files and install the dependencies. this project is set up with `yarn` 34 | 35 | ``` 36 | $ git clone https://github.com/Alex61NN5/angular-universal-heroku-starter.git 37 | $ cd angular-universal-heroku-starter 38 | ``` 39 | then run `yarn` 40 | 41 | The `package.json` has an engines section that specifies the node and yarn version to use for the heroku build 42 | 43 | In your terminal run the following commands 44 | ``` 45 | $ node -v 46 | $ yarn -v // or npm -v 47 | ``` 48 | now either update your node and yarn/npm to match the ones found in the package.json or change the engines to match your versions otherwise when you try to install packages it will throw an error 49 | 50 | ``` 51 | "engines": { 52 | "node": "10.16.3", 53 | "yarn": "1.5.1" 54 | }, 55 | ``` 56 | 57 | If you wish to use `npm` instead make sure you delete the `yarn.lock` file from the project and then change the `engines` to use the version of `npm` you are running to find this out run `npm -v` an example of what this would look like is 58 | 59 | ``` 60 | "engines": { 61 | "node": "10.16.3", 62 | "npm": "6.4.1" 63 | }, 64 | ``` 65 | **IMPORTANT** 66 | You will probably want to change the project name so what you will need to do is do a find and replace of `angular-universal-heroku-starter` and change everything to your new project name. Most of this stuff will be in the angular.json 67 | 68 | 69 | ### Development 70 | 71 | To run this project for development you can use the command `ng serve` or `npm start` 72 | 73 | This project uses [husky](https://github.com/typicode/husky) to implement git-hooks and [commitLint](https://github.com/marionebl/commitlint) to check commit messages. If you do not wish to use these features remove this from your package.json 74 | 75 | ``` 76 | "husky": { 77 | "hooks": { 78 | "pre-commit": "ng lint", 79 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" 80 | } 81 | }, 82 | ``` 83 | remove the `commitlint.config.js` file from the src directory and then run 84 | 85 | `yarn remove husky @commitlint/cli @commitlint/config-angular` 86 | 87 | ### Test Production/Server Side Rendering 88 | 89 | `npm run build:ssr` - Compiles your application and spins up a Node Express to serve your Universal application on http://localhost:4000 90 | 91 | ## Heroku 92 | 93 | **IMPORTANT** For the heroku deploy to work correctly you must change this line in your package.json to match the new name of the project 94 | 95 | `"build:client-and-server-bundles": "ng build --prod && ng run :server"` 96 | 97 | #### To deploy to heroku 98 | 99 | ``` 100 | $ git init 101 | $ heroku login 102 | $ heroku create 103 | $ git add . 104 | $ git commit -m "initial commit" 105 | $ git push heroku master 106 | $ heroku open 107 | ``` 108 | 109 | ## PWA 110 | 111 | This project is now a Progressive Web Application, this was achieved by running `ng add @angular/pwa`. 112 | 113 | Some things to keep in mind, 114 | 1. You will need to update the pwa icons located in the assets folder to match your application 115 | 2. You will need to update your manifest.json to reflect your application for eg. 116 | 117 | ``` 118 | { 119 | "name": "Your application name here", 120 | "short_name": "Short name for application", 121 | "theme_color": "#1976d2", // Colour Theme 122 | "background_color": "#fafafa", // Background colour 123 | "display": "standalone", 124 | "scope": "/", 125 | "start_url": "/", 126 | ... 127 | ``` 128 | 3. In the ngsw-config.json file if you plan on having a `sitemap.xml` or `robots.txt` you will need to add them to the resources section 129 | 130 | Currently the application is getting a 92 lighthouse score, there are two issues http to https which unfortuantely is unavoidable with heroku, and the `short_name` is too long but you will need to update that anyway which will fix this issue and your score will be closer to 100 131 | 132 | ## Universal "Gotchas" 133 | 134 | https://github.com/angular/universal/blob/master/docs/gotchas.md 135 | 136 | ### Contribution 137 | 138 | Before contributing please read the [contribution guidelines](https://github.com/Alex61NN5/angular-universal-heroku-starter/blob/master/CONTRIBUTING.md) 139 | 140 | ### Licence 141 |
142 | 143 | [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](/LICENSE) 144 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "angular-universal-heroku": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": { 12 | "@schematics/angular:component": { 13 | "styleext": "scss" 14 | } 15 | }, 16 | "architect": { 17 | "build": { 18 | "builder": "@angular-devkit/build-angular:browser", 19 | "options": { 20 | "outputPath": "dist/browser", 21 | "index": "src/index.html", 22 | "main": "src/main.ts", 23 | "polyfills": "src/polyfills.ts", 24 | "tsConfig": "src/tsconfig.app.json", 25 | "assets": [ 26 | "src/favicon.ico", 27 | "src/assets", 28 | "src/manifest.json" 29 | ], 30 | "styles": [ 31 | "src/styles.scss" 32 | ], 33 | "scripts": [] 34 | }, 35 | "configurations": { 36 | "production": { 37 | "fileReplacements": [ 38 | { 39 | "replace": "src/environments/environment.ts", 40 | "with": "src/environments/environment.prod.ts" 41 | } 42 | ], 43 | "optimization": true, 44 | "outputHashing": "all", 45 | "sourceMap": false, 46 | "extractCss": true, 47 | "namedChunks": false, 48 | "aot": true, 49 | "extractLicenses": true, 50 | "vendorChunk": false, 51 | "buildOptimizer": true, 52 | "budgets": [ 53 | { 54 | "type": "initial", 55 | "maximumWarning": "2mb", 56 | "maximumError": "5mb" 57 | } 58 | ], 59 | "serviceWorker": true 60 | } 61 | } 62 | }, 63 | "serve": { 64 | "builder": "@angular-devkit/build-angular:dev-server", 65 | "options": { 66 | "browserTarget": "angular-universal-heroku:build" 67 | }, 68 | "configurations": { 69 | "production": { 70 | "browserTarget": "angular-universal-heroku:build:production" 71 | } 72 | } 73 | }, 74 | "extract-i18n": { 75 | "builder": "@angular-devkit/build-angular:extract-i18n", 76 | "options": { 77 | "browserTarget": "angular-universal-heroku:build" 78 | } 79 | }, 80 | "test": { 81 | "builder": "@angular-devkit/build-angular:karma", 82 | "options": { 83 | "main": "src/test.ts", 84 | "polyfills": "src/polyfills.ts", 85 | "tsConfig": "src/tsconfig.spec.json", 86 | "karmaConfig": "src/karma.conf.js", 87 | "styles": [ 88 | "src/styles.scss" 89 | ], 90 | "scripts": [], 91 | "assets": [ 92 | "src/favicon.ico", 93 | "src/assets", 94 | "src/manifest.json" 95 | ] 96 | } 97 | }, 98 | "lint": { 99 | "builder": "@angular-devkit/build-angular:tslint", 100 | "options": { 101 | "tsConfig": [ 102 | "src/tsconfig.app.json", 103 | "src/tsconfig.spec.json" 104 | ], 105 | "exclude": [ 106 | "**/node_modules/**" 107 | ] 108 | } 109 | }, 110 | "server": { 111 | "builder": "@angular-devkit/build-angular:server", 112 | "options": { 113 | "outputPath": "dist/server", 114 | "main": "src/main.server.ts", 115 | "tsConfig": "src/tsconfig.server.json" 116 | } 117 | } 118 | } 119 | }, 120 | "angular-universal-heroku-e2e": { 121 | "root": "e2e/", 122 | "projectType": "application", 123 | "prefix": "", 124 | "architect": { 125 | "e2e": { 126 | "builder": "@angular-devkit/build-angular:protractor", 127 | "options": { 128 | "protractorConfig": "e2e/protractor.conf.js", 129 | "devServerTarget": "angular-universal-heroku:serve" 130 | }, 131 | "configurations": { 132 | "production": { 133 | "devServerTarget": "angular-universal-heroku:serve:production" 134 | } 135 | } 136 | }, 137 | "lint": { 138 | "builder": "@angular-devkit/build-angular:tslint", 139 | "options": { 140 | "tsConfig": "e2e/tsconfig.e2e.json", 141 | "exclude": [ 142 | "**/node_modules/**" 143 | ] 144 | } 145 | } 146 | } 147 | } 148 | }, 149 | "defaultProject": "angular-universal-heroku" 150 | } -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = {extends: ['@commitlint/config-angular']}; 2 | -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.e2e.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; -------------------------------------------------------------------------------- /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 angular-universal-heroku!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /local.js: -------------------------------------------------------------------------------- 1 | // generated by @ng-toolkit/universal 2 | const port = process.env.PORT || 8080; 3 | 4 | const server = require('./dist/server'); 5 | 6 | server.app.listen(port, () => { 7 | console.log("Listening on: http://localhost:" + port ); 8 | }); 9 | -------------------------------------------------------------------------------- /ng-toolkit.json: -------------------------------------------------------------------------------- 1 | { 2 | "universal": { 3 | "project": "angular-universal-heroku", 4 | "skipInstall": false, 5 | "directory": "." 6 | } 7 | } -------------------------------------------------------------------------------- /ngsw-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "index": "/index.html", 3 | "assetGroups": [ 4 | { 5 | "name": "app", 6 | "installMode": "prefetch", 7 | "resources": { 8 | "files": [ 9 | "/favicon.ico", 10 | "/index.html", 11 | "/*.css", 12 | "/*.js" 13 | ] 14 | } 15 | }, { 16 | "name": "assets", 17 | "installMode": "lazy", 18 | "updateMode": "prefetch", 19 | "resources": { 20 | "files": [ 21 | "/assets/**" 22 | ] 23 | } 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-universal-heroku", 3 | "version": "0.0.0", 4 | "engines": { 5 | "node": "10.16.3", 6 | "yarn": "1.5.1" 7 | }, 8 | "scripts": { 9 | "start:heroku": "node dist/server", 10 | "heroku-postbuild": "npm run build:ssr", 11 | "ng": "ng", 12 | "start": "ng serve", 13 | "build": "ng build", 14 | "lint": "ng lint --fix", 15 | "build:client-and-server-bundles": "ng build --prod && ng run angular-universal-heroku:server", 16 | "build:prerender": "npm run build:client-and-server-bundles && npm run webpack:server && npm run generate:prerender", 17 | "build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server", 18 | "generate:prerender": "cd dist && node prerender", 19 | "webpack:server": "webpack --config webpack.server.config.js --progress --colors", 20 | "serve:prerender": "cd dist/browser && http-server", 21 | "serve:ssr": "node dist/server" 22 | }, 23 | "private": true, 24 | "dependencies": { 25 | "@angular/animations": "8.2.9", 26 | "@angular/common": "8.2.9", 27 | "@angular/compiler": "8.2.9", 28 | "@angular/core": "8.2.9", 29 | "@angular/forms": "8.2.9", 30 | "@angular/http": "7.0.3", 31 | "@angular/platform-browser": "8.2.9", 32 | "@angular/platform-browser-dynamic": "8.2.9", 33 | "@angular/platform-server": "8.2.9", 34 | "@angular/pwa": "^0.12.0", 35 | "@angular/router": "8.2.9", 36 | "@angular/service-worker": "8.2.9", 37 | "@commitlint/cli": "7.2.1", 38 | "@commitlint/config-angular": "7.1.2", 39 | "@ng-toolkit/universal": "1.1.47", 40 | "@nguniversal/express-engine": "8.1.1", 41 | "@nguniversal/module-map-ngfactory-loader": "8.1.1", 42 | "core-js": "2.5.7", 43 | "cors": "2.8.5", 44 | "express": "4.17.1", 45 | "husky": "1.3.1", 46 | "rxjs": "6.5.3", 47 | "ts-loader": "4.2.0", 48 | "webpack": "^4.3.0", 49 | "webpack-cli": "3.3.9", 50 | "zone.js": "0.9.1" 51 | }, 52 | "devDependencies": { 53 | "@angular-devkit/build-angular": "0.803.8", 54 | "@angular/cli": "8.3.8", 55 | "@angular/compiler-cli": "8.2.9", 56 | "@angular/language-service": "8.2.9", 57 | "@types/jasmine": "2.8.14", 58 | "@types/jasminewd2": "2.0.6", 59 | "@types/node": "8.10.39", 60 | "codelyzer": "4.5.0", 61 | "jasmine-core": "2.99.1", 62 | "jasmine-spec-reporter": "4.2.1", 63 | "karma": "3.1.4", 64 | "karma-chrome-launcher": "2.2.0", 65 | "karma-coverage-istanbul-reporter": "2.0.4", 66 | "karma-jasmine": "1.1.2", 67 | "karma-jasmine-html-reporter": "0.2.2", 68 | "protractor": "5.4.1", 69 | "ts-node": "7.0.1", 70 | "tslint": "5.12.0", 71 | "typescript": "3.5.3" 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /server.ts: -------------------------------------------------------------------------------- 1 | import 'zone.js/dist/zone-node'; 2 | import 'reflect-metadata'; 3 | import {enableProdMode} from '@angular/core'; 4 | 5 | import * as express from 'express'; 6 | import {join} from 'path'; 7 | import {readFileSync} from 'fs'; 8 | 9 | // Faster server renders w/ Prod mode (dev mode never needed) 10 | enableProdMode(); 11 | 12 | // Express server 13 | const app = express(); 14 | 15 | const PORT = process.env.PORT || 4000; 16 | const DIST_FOLDER = join(process.cwd(), 'dist'); 17 | 18 | // Our index.html we'll use as our template 19 | const template = readFileSync(join(DIST_FOLDER, 'browser', 'index.html')).toString(); 20 | 21 | // * NOTE :: leave this as require() since this file is built Dynamically from webpack 22 | const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/server/main'); 23 | 24 | // Express Engine 25 | import {ngExpressEngine} from '@nguniversal/express-engine'; 26 | // Import module map for lazy loading 27 | import {provideModuleMap} from '@nguniversal/module-map-ngfactory-loader'; 28 | 29 | // Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine) 30 | app.engine('html', ngExpressEngine({ 31 | bootstrap: AppServerModuleNgFactory, 32 | providers: [ 33 | provideModuleMap(LAZY_MODULE_MAP) 34 | ] 35 | })); 36 | 37 | app.set('view engine', 'html'); 38 | app.set('views', join(DIST_FOLDER, 'browser')); 39 | 40 | /* - Example Express Rest API endpoints - 41 | app.get('/api/**', (req, res) => { }); 42 | */ 43 | 44 | // Server static files from /browser 45 | app.get('*.*', express.static(join(DIST_FOLDER, 'browser'), { 46 | maxAge: '1y' 47 | })); 48 | 49 | // ALl regular routes use the Universal engine 50 | app.get('*', (req, res) => { 51 | res.render('index', { req }); 52 | }); 53 | 54 | // Start up the Node server 55 | app.listen(PORT, () => { 56 | console.log(`Node Express server listening on http://localhost:${PORT}`); 57 | }); 58 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | import { CommonModule } from '@angular/common'; 4 | import { NotFoundComponent } from './not-found/not-found.component'; 5 | 6 | const routes: Routes = [ 7 | { path: '404', component: NotFoundComponent }, 8 | {path: '**', redirectTo: '/404', pathMatch: 'full'} 9 | ]; 10 | 11 | @NgModule({ 12 | imports: [RouterModule.forRoot(routes)], 13 | exports: [RouterModule] 14 | }) 15 | export class AppRoutingModule { } 16 | -------------------------------------------------------------------------------- /src/app/app.browser.module.ts: -------------------------------------------------------------------------------- 1 | import { AppComponent } from './app.component'; 2 | import { AppModule } from './app.module'; 3 | import { NgModule } from '@angular/core'; 4 | import { BrowserModule } from '@angular/platform-browser'; 5 | import { ServiceWorkerModule } from '@angular/service-worker'; 6 | import { environment } from '../environments/environment'; 7 | 8 | @NgModule({ 9 | bootstrap: [ 10 | AppComponent 11 | ], 12 | 13 | imports: [ 14 | BrowserModule.withServerTransition({ 15 | appId: 'app-root' 16 | }), 17 | AppModule, 18 | ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }), 19 | ] 20 | }) 21 | export class AppBrowserModule {} 22 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

4 | Welcome to {{ title }}! 5 |

6 | Angular Logo 7 |
8 |

Here are some links to help you start:

9 | 20 | 21 | -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alex61NN5/angular-universal-pwa-heroku-starter/b6726a7cd0f44bae45b45e9058acce4adfe0303f/src/app/app.component.scss -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | 4 | describe('AppComponent', () => { 5 | beforeEach(async(() => { 6 | TestBed.configureTestingModule({ 7 | declarations: [ 8 | AppComponent 9 | ], 10 | }).compileComponents(); 11 | })); 12 | 13 | it('should create the app', () => { 14 | const fixture = TestBed.createComponent(AppComponent); 15 | const app = fixture.debugElement.componentInstance; 16 | expect(app).toBeTruthy(); 17 | }); 18 | 19 | it(`should have as title 'angular-universal-heroku'`, () => { 20 | const fixture = TestBed.createComponent(AppComponent); 21 | const app = fixture.debugElement.componentInstance; 22 | expect(app.title).toEqual('angular-universal-heroku'); 23 | }); 24 | 25 | it('should render title in a h1 tag', () => { 26 | const fixture = TestBed.createComponent(AppComponent); 27 | fixture.detectChanges(); 28 | const compiled = fixture.debugElement.nativeElement; 29 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to angular-universal-heroku!'); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.scss'] 7 | }) 8 | export class AppComponent { 9 | title = 'angular-universal-heroku'; 10 | } 11 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgtUniversalModule } from '@ng-toolkit/universal'; 2 | import { CommonModule } from '@angular/common'; 3 | import { BrowserModule } from '@angular/platform-browser'; 4 | import { NgModule } from '@angular/core'; 5 | 6 | import { AppComponent } from './app.component'; 7 | import { AppRoutingModule } from './app-routing.module'; 8 | import { NotFoundComponent } from './not-found/not-found.component'; 9 | 10 | @NgModule({ 11 | declarations: [ 12 | AppComponent, 13 | NotFoundComponent 14 | ], 15 | imports: [ 16 | CommonModule, 17 | NgtUniversalModule, 18 | AppRoutingModule, 19 | ], 20 | providers: [], 21 | }) 22 | export class AppModule { } 23 | -------------------------------------------------------------------------------- /src/app/app.server.module.ts: -------------------------------------------------------------------------------- 1 | import { AppComponent } from './app.component'; 2 | import { AppModule } from './app.module'; 3 | import { NgModule } from '@angular/core'; 4 | import { ServerModule, ServerTransferStateModule } from '@angular/platform-server'; 5 | import { ModuleMapLoaderModule } from '@nguniversal/module-map-ngfactory-loader'; 6 | import { BrowserModule } from '@angular/platform-browser'; 7 | import { NoopAnimationsModule } from '@angular/platform-browser/animations'; 8 | 9 | @NgModule({ 10 | bootstrap: [AppComponent], 11 | 12 | imports: [ 13 | BrowserModule.withServerTransition({ 14 | appId: 'app-root' 15 | }), 16 | 17 | AppModule, 18 | 19 | ServerModule, 20 | NoopAnimationsModule, 21 | ModuleMapLoaderModule, 22 | ServerTransferStateModule, // comment 23 | ] 24 | }) 25 | export class AppServerModule {} 26 | -------------------------------------------------------------------------------- /src/app/not-found/not-found.component.html: -------------------------------------------------------------------------------- 1 |

2 | not-found works! 3 |

4 | -------------------------------------------------------------------------------- /src/app/not-found/not-found.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alex61NN5/angular-universal-pwa-heroku-starter/b6726a7cd0f44bae45b45e9058acce4adfe0303f/src/app/not-found/not-found.component.scss -------------------------------------------------------------------------------- /src/app/not-found/not-found.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { NotFoundComponent } from './not-found.component'; 4 | 5 | describe('NotFoundComponent', () => { 6 | let component: NotFoundComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ NotFoundComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(NotFoundComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/not-found/not-found.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-not-found', 5 | templateUrl: './not-found.component.html', 6 | styleUrls: ['./not-found.component.scss'] 7 | }) 8 | export class NotFoundComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | console.log('logged called'); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alex61NN5/angular-universal-pwa-heroku-starter/b6726a7cd0f44bae45b45e9058acce4adfe0303f/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/assets/icons/icon-128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alex61NN5/angular-universal-pwa-heroku-starter/b6726a7cd0f44bae45b45e9058acce4adfe0303f/src/assets/icons/icon-128x128.png -------------------------------------------------------------------------------- /src/assets/icons/icon-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alex61NN5/angular-universal-pwa-heroku-starter/b6726a7cd0f44bae45b45e9058acce4adfe0303f/src/assets/icons/icon-144x144.png -------------------------------------------------------------------------------- /src/assets/icons/icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alex61NN5/angular-universal-pwa-heroku-starter/b6726a7cd0f44bae45b45e9058acce4adfe0303f/src/assets/icons/icon-152x152.png -------------------------------------------------------------------------------- /src/assets/icons/icon-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alex61NN5/angular-universal-pwa-heroku-starter/b6726a7cd0f44bae45b45e9058acce4adfe0303f/src/assets/icons/icon-192x192.png -------------------------------------------------------------------------------- /src/assets/icons/icon-384x384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alex61NN5/angular-universal-pwa-heroku-starter/b6726a7cd0f44bae45b45e9058acce4adfe0303f/src/assets/icons/icon-384x384.png -------------------------------------------------------------------------------- /src/assets/icons/icon-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alex61NN5/angular-universal-pwa-heroku-starter/b6726a7cd0f44bae45b45e9058acce4adfe0303f/src/assets/icons/icon-512x512.png -------------------------------------------------------------------------------- /src/assets/icons/icon-72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alex61NN5/angular-universal-pwa-heroku-starter/b6726a7cd0f44bae45b45e9058acce4adfe0303f/src/assets/icons/icon-72x72.png -------------------------------------------------------------------------------- /src/assets/icons/icon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alex61NN5/angular-universal-pwa-heroku-starter/b6726a7cd0f44bae45b45e9058acce4adfe0303f/src/assets/icons/icon-96x96.png -------------------------------------------------------------------------------- /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 | # 5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed 6 | 7 | > 0.5% 8 | last 2 versions 9 | Firefox ESR 10 | not dead 11 | not IE 9-11 -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /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 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alex61NN5/angular-universal-pwa-heroku-starter/b6726a7cd0f44bae45b45e9058acce4adfe0303f/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AngularUniversalHeroku 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /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 | }; -------------------------------------------------------------------------------- /src/main.server.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { environment } from './environments/environment'; 3 | 4 | if (environment.production) { 5 | enableProdMode(); 6 | } 7 | 8 | export { 9 | AppServerModule 10 | } 11 | from './app/app.server.module'; 12 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { AppBrowserModule } from '.././src/app/app.browser.module'; 2 | import { enableProdMode } from '@angular/core'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | import { AppModule } from './app/app.module'; 6 | import { environment } from './environments/environment'; 7 | 8 | if (environment.production) { 9 | enableProdMode(); 10 | } 11 | 12 | platformBrowserDynamic().bootstrapModule(AppBrowserModule) 13 | .catch(err => console.error(err)); 14 | -------------------------------------------------------------------------------- /src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-universal-heroku", 3 | "short_name": "angular-universal-heroku", 4 | "theme_color": "#1976d2", 5 | "background_color": "#fafafa", 6 | "display": "standalone", 7 | "scope": "/", 8 | "start_url": "/", 9 | "icons": [ 10 | { 11 | "src": "assets/icons/icon-72x72.png", 12 | "sizes": "72x72", 13 | "type": "image/png" 14 | }, 15 | { 16 | "src": "assets/icons/icon-96x96.png", 17 | "sizes": "96x96", 18 | "type": "image/png" 19 | }, 20 | { 21 | "src": "assets/icons/icon-128x128.png", 22 | "sizes": "128x128", 23 | "type": "image/png" 24 | }, 25 | { 26 | "src": "assets/icons/icon-144x144.png", 27 | "sizes": "144x144", 28 | "type": "image/png" 29 | }, 30 | { 31 | "src": "assets/icons/icon-152x152.png", 32 | "sizes": "152x152", 33 | "type": "image/png" 34 | }, 35 | { 36 | "src": "assets/icons/icon-192x192.png", 37 | "sizes": "192x192", 38 | "type": "image/png" 39 | }, 40 | { 41 | "src": "assets/icons/icon-384x384.png", 42 | "sizes": "384x384", 43 | "type": "image/png" 44 | }, 45 | { 46 | "src": "assets/icons/icon-512x512.png", 47 | "sizes": "512x512", 48 | "type": "image/png" 49 | } 50 | ] 51 | } -------------------------------------------------------------------------------- /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/guide/browser-support 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 | /** 38 | * If the application will be indexed by Google Search, the following is required. 39 | * Googlebot uses a renderer based on Chrome 41. 40 | * https://developers.google.com/search/docs/guides/rendering 41 | **/ 42 | // import 'core-js/es6/array'; 43 | 44 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 45 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 46 | 47 | /** IE10 and IE11 requires the following for the Reflect API. */ 48 | // import 'core-js/es6/reflect'; 49 | 50 | /** 51 | * Web Animations `@angular/platform-browser/animations` 52 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 53 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 54 | **/ 55 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 56 | 57 | /** 58 | * By default, zone.js will patch all possible macroTask and DomEvents 59 | * user can disable parts of macroTask/DomEvents patch by setting following flags 60 | */ 61 | 62 | // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 63 | // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 64 | // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 65 | 66 | /* 67 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 68 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 69 | */ 70 | // (window as any).__Zone_enable_cross_context_check = true; 71 | 72 | /*************************************************************************************************** 73 | * Zone JS is required by default for Angular itself. 74 | */ 75 | import 'zone.js/dist/zone'; // Included with Angular CLI. 76 | 77 | 78 | /*************************************************************************************************** 79 | * APPLICATION IMPORTS 80 | */ 81 | -------------------------------------------------------------------------------- /src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "types": [] 6 | }, 7 | "exclude": [ 8 | "test.ts", 9 | "**/*.spec.ts" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/tsconfig.server.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "types": [ 8 | "node" 9 | ] 10 | }, 11 | "exclude": [ 12 | "test.ts", 13 | "**/*.spec.ts" 14 | ], 15 | "angularCompilerOptions": { 16 | "entryModule": "app/app.server.module#AppServerModule" 17 | }, 18 | "include": [ 19 | "**/*.ts" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "test.ts", 12 | "polyfills.ts" 13 | ], 14 | "include": [ 15 | "**/*.spec.ts", 16 | "**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "module": "es2015", 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "target": "es5", 13 | "typeRoots": [ 14 | "node_modules/@types" 15 | ], 16 | "lib": [ 17 | "es2018", 18 | "dom" 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /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-redundant-jsdoc": true, 69 | "no-shadowed-variable": true, 70 | "no-string-literal": false, 71 | "no-string-throw": true, 72 | "no-switch-case-fall-through": true, 73 | "no-trailing-whitespace": true, 74 | "no-unnecessary-initializer": true, 75 | "no-unused-expression": true, 76 | "no-use-before-declare": true, 77 | "no-var-keyword": true, 78 | "object-literal-sort-keys": false, 79 | "one-line": [ 80 | true, 81 | "check-open-brace", 82 | "check-catch", 83 | "check-else", 84 | "check-whitespace" 85 | ], 86 | "prefer-const": true, 87 | "quotemark": [ 88 | true, 89 | "single" 90 | ], 91 | "radix": true, 92 | "semicolon": [ 93 | true, 94 | "always" 95 | ], 96 | "triple-equals": [ 97 | true, 98 | "allow-null-check" 99 | ], 100 | "typedef-whitespace": [ 101 | true, 102 | { 103 | "call-signature": "nospace", 104 | "index-signature": "nospace", 105 | "parameter": "nospace", 106 | "property-declaration": "nospace", 107 | "variable-declaration": "nospace" 108 | } 109 | ], 110 | "unified-signatures": true, 111 | "variable-name": false, 112 | "whitespace": [ 113 | true, 114 | "check-branch", 115 | "check-decl", 116 | "check-operator", 117 | "check-separator", 118 | "check-type" 119 | ], 120 | "no-output-on-prefix": true, 121 | "use-input-property-decorator": true, 122 | "use-output-property-decorator": true, 123 | "use-host-property-decorator": true, 124 | "no-input-rename": true, 125 | "no-output-rename": true, 126 | "use-life-cycle-interface": true, 127 | "use-pipe-transform-interface": true, 128 | "component-class-suffix": true, 129 | "directive-class-suffix": true 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /webpack.server.config.js: -------------------------------------------------------------------------------- 1 | 2 | // Work around for https://github.com/angular/angular-cli/issues/7200 3 | 4 | const path = require('path'); 5 | const webpack = require('webpack'); 6 | 7 | module.exports = { 8 | entry: { 9 | server: './server.ts', 10 | }, 11 | target: 'node', 12 | resolve: { extensions: ['.ts', '.js'] }, 13 | externals: [/(node_modules|main\..*\.js)/,], 14 | output: { 15 | libraryTarget: 'commonjs2', 16 | path: path.join(__dirname, 'dist'), 17 | filename: '[name].js' 18 | }, 19 | module: { 20 | rules: [ 21 | { test: /\.ts$/, loader: 'ts-loader' } 22 | ] 23 | }, 24 | optimization: { 25 | minimize: false 26 | }, 27 | plugins: [ 28 | new webpack.ContextReplacementPlugin( 29 | // fixes WARNING Critical dependency: the request of a dependency is an expression 30 | /(.+)?angular(\\|\/)core(.+)?/, 31 | path.join(__dirname, 'src'), // location of your src 32 | {} // a map of your routes 33 | ), 34 | new webpack.ContextReplacementPlugin( 35 | // fixes WARNING Critical dependency: the request of a dependency is an expression 36 | /(.+)?express(\\|\/)(.+)?/, 37 | path.join(__dirname, 'src'), 38 | {} 39 | ) 40 | ] 41 | } 42 | --------------------------------------------------------------------------------