Search code examples
amazon-web-servicesangularamazon-s3amazon-ec2angular2-routing

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...


Solution

  • 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.