我是webpack的新手,并使用angularclass的angular2 starter pack和rc6。
一切都很顺利,但对于我所做的部署到生产有疑问,似乎与nginx和主管合作。
所以我做了以下部署:
npm run build:prod
npm run server:prod
主管会议
[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
我的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;
}
}
然后在nginx的dist /文件夹中提供app
那么在构建和运行的过程中,webpack进程会自动添加以下内容吗?还是有另一步。
enableProdMode()
我还缺少部署和生产angular2应用程序吗?