1

I am new to webpack and using the angular2 starter pack from angularclass with rc6.

All is well but have questions about deploying to production which I did and seemed to work with nginx and supervisor.

So I did the below to deploy:

npm run build:prod
npm run server:prod

Supervisor Conf

[program:angular]
directory=/var/my-angular2/
autostart=true
autorestart=true
process_name = angular-%(process_num)s
command = npm run server:prod

--port=%(process_num)s
--log_file_prefix=%(here)s/logs/%(program_name)s-%(process_num)s.log

[group:angular_server]
programs=angular

My Nginx Conf

server {

     listen 80 default_server;
     listen [::]:80 default_server;
     root /var/my-angular2/dist;

     # Add index.php to the list if you are using PHP
     index index.html index.htm index.php index.nginx-debian.html;


     # Here we proxy pass only the base path
     location = / {
         proxy_set_header   X-Real-IP $remote_addr;
         proxy_set_header   Host      $http_host;
         proxy_pass         http://127.0.0.1:8080;
     }

         # Here we proxy pass all the browsersync stuff including
         # all the websocket traffic
       location /browser-sync {
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_pass         http://127.0.0.1:8080;
            proxy_http_version 1.1;
            proxy_set_header   Upgrade $http_upgrade;
            proxy_set_header   Connection "upgrade";
            proxy_set_header   Host $host;
        }


 }

Then served app out of the dist/ folder in nginx

So in the process of building and running does the webpack process automatically add the below? Or is there another step.

    enableProdMode()  

When else am I missing for deploying and production angular2 app?

Tampa
  • 75,446
  • 119
  • 278
  • 425

0 Answers0