1
votes

For past Angular 2 projects, I would upload the static dist folder from Angular CLI build to Google Cloud Platform. I would use the SDK with command gcloud app deploy app.yaml with this app.yaml file:

application: 
version: 
runtime: python27
threadsafe: true
api_version: 1

handlers:
- url: /(.*\.(gif|png|jpeg|jpg|css|js)(|\.map))$
  static_files: dist/\1
  upload: dist/(.*)(|\.map)

- url: /(.*)
  static_files: dist/index.html
  upload: dist/index.html

I have started using the Universal-CLI. It too produces a dist folder with the ung build command.

The documentation outlines two approaches for server rendering. Is this dist folder what they mean by the first approach:

The first option is to pre-render your application which means that you would use one of the Universal build tools (i.e. gulp, grunt, broccoli, webpack, etc.) to generate static HTML for all your routes at build time. Then you could deploy that static HTML to a CDN.

Is Angular Universal working as intended if I deploy dist folder in the same way as I was doing for past angular 2 projects outlined above?

If not how should an Angular Universal project be deployed?

1

1 Answers

0
votes

A bit late here. Either way, in case someone is still looking for this.

This is what I ended up doing. I transferred my code repo (the folder containing the entire app minus the node_modules etc.) into the domain folder. (public_html or whatever you are using)

After this, I ran these two commands.

npm install
npm start

Basically, install all the required dependencies in your server as well and start your server.

The second command, npm start is directly applicable in case you have built your project from the brilliant starter app from here for Angular CLI and Universal. If not, use whatever commands you use for starting up your app in development.