如何部署我的 Angular 2 + Typescript + Webpack 应用程序 [英] How can I deploy my Angular 2 + Typescript + Webpack app
问题描述
我实际上是在用 Typescript 学习 Angular 2 并基于 angular-seed 项目开发了一个小应用程序 (角种子).我已经为生产目的构建了应用程序,并准备好部署 dist 文件夹,其中包含我的包文件,如下所示:
I am actually learning Angular 2 with Typescript and developed a little app by based on the angular-seed project (angular-seed). I have built the app for production purposes and got dist folder ready to be deployed containing my bundle files like this:
dist/
main.bundle.js
main.map
polyfills.bundle.js
polyfills.map
vendor.bundle.js
vendor.map
但是,作为新手,我现在不知道如何在我的 EC2 服务器上部署它.我读到我必须配置 Nginx 服务器才能为我的静态文件提供服务,但我是否必须专门配置它才能使用我的包文件?
However, as a fresher, I have no idea how to deploy it now on my EC2 server. I read that I have to config Nginx server to serve my static file but do I have to config it particularly to work with my bundle files?
请原谅我的错误(如果有的话).非常感谢提前!
Excuse my mistakes if any. Thanks a lot in advance!
推荐答案
你走在正确的轨道上......
You are on the right track.....
只需在您的 EC2 上安装 nginx.就我而言,我在Digital Ocean"上安装了 linux Ubuntu 14.04.
Just install the nginx on your EC2. In my case I had a linux Ubuntu 14.04 installed on "Digital Ocean".
首先我更新了 apt-get 包列表:
First I updated the apt-get package lists:
sudo apt-get update
然后使用apt-get安装Nginx:
Then install Nginx using apt-get:
sudo apt-get install nginx
然后打开默认的服务器块配置文件进行
Then open the default server block configuration file for editing:
sudo vi /etc/nginx/sites-available/default
删除此配置文件中的所有内容并粘贴以下内容:
Delete everything in this configuration file and paste the following content:
server {
listen 80 default_server;
root /path/dist-nginx;
index index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
}
要使更改生效,请重新启动网络服务器 nginx:
To make the changes active, restart the webserver nginx:
sudo service nginx restart
然后将 index.html 和捆绑文件复制到您服务器上的 /path/dist-nginx
并启动并运行.
Then copy index.html and the bundle files to /path/dist-nginx
on your server and you are up and running.
这篇关于如何部署我的 Angular 2 + Typescript + Webpack 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!