简体   繁体   中英

how to deploy an Angular2 Typescript based application is AWS S3

I want to deploy Angular 2 in a static server .I do not want to deploy it with Node. Js. Is it possible to run Angular Based application in AWS S3? How to deploy it to S3...

Use Angular CLI .

With that you can generate a production folder (dist) with index.html and all the assets, then you can deploy that folder to a static server.

Package your application to the dist folder by using the following command to generate transpiled js files and the other image, css assets and then upload to AWS S3.

Angular CLI: ng build -prod WebPack: npm run build_prod

Not sure if pretty urls will be full supported on page refresh but I use the following in Nginx to forward all url requests back to index.html

location / {
    try_files $uri $uri/ /index.html?$query_string;
}

Finally: I would still recommend hosting any web app in a real web server if you can but any system that can serve files through http should definitely work.

在“ S3存储桶静态主机错误”页面中,将其设置为index.html,以允许路由器导航为组件指定的路由,除非您使用CD / CI框架进行部署,否则必须上载node_modules文件夹,否则将部署已安装模块自动。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM