Skip to content

Implemented Server Side Rendering using Angular Universal (SEO Friendly) #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,43 @@

[![Build Status](https://travis-ci.com/meetdave3/Angular6-Node.js-TypeScript.svg?branch=master)](https://travis-ci.com/meetdave3/Angular6-Node.js-TypeScript)

This project is a starter project with Node at the backend (fully written in TypeScript) and Angular 6 at the frontend.
This project is a starter project with Node at the backend (fully written in TypeScript) and Angular 6 on the client side.

This repo shall allow you to instantly get started with a full stack project in place. Just connect it with your favorite database and you're good to go.

## Repo Features

- [x] Angular 6.0.0
- [x] Angular 6.0.9
- [x] Bootstrap
- [x] Lazy Loaded Routes
- [x] Angular Material
- [x] PWA
- [x] PWA Ready
- [x] Server Side TypeScript
- [x] Node.js API
- [x] Production Ready Build
- [x] Server Side Rendering (Angular Universal)

## Setup

After cloning, run `npm install`

## Development server

Run `ng build --watch`
Run `ng serve`

After the --watch build, `npm run dev` for a dev server. Navigate to `http://localhost:3000/`.

The app will automatically reload if you change any of the source files. (Server side as well as client side)
Navigate to `http://localhost:4200/`.

## Code scaffolding

Run `ng g c component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.

## Production Build

First run `ng build --prod` to build the project
Run `npm run build:ssr && npm run serve:ssr` to build the project

Compiles the boiler application and spins up a Node Express to serve the Boiler Universal application on http://localhost:3000

Then, `npm run prod` to start the node server for production. The build artifacts will be stored in the `dist/` directory.
`npm run build:prerender && npm run serve:prerender` - Compiles your application and prerenders your application's files, spinning up a demo http-server so you can view it on http://localhost:8080 Note: To deploy your static site to a static hosting platform you will have to deploy the dist/browser folder, rather than the usual dist

## Running unit tests

Expand Down
20 changes: 19 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"outputPath": "dist/browser",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
Expand Down Expand Up @@ -48,6 +48,24 @@
}
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/server",
"main": "src/main.server.ts",
"tsConfig": "src/tsconfig.server.json"
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
Expand Down
Loading