简体   繁体   中英

Deploy Angular 2 app on AWS S3

How to deploy Angular 2 app on aws s3 ? Do I need to upload only src folder or with node_modules ? Is there anything I need to do with my code ?

I have aws panel to upload files through browse. Please help me to go ahead.

Anyone else seeing this question -> see this first: How to bundle an Angular app for production It basically says to run

ng build --prod --aot

After that just upload your dist folder to an S3 bucket that has 'Static Web Hosting' enabled in the properties tab of the bucket + give it a bucket policy that lets everyone grab from it similar to:

{
"Version": "2012-10-17",
"Statement": [
    {
        "Sid": "AddPerm",
        "Effect": "Allow",
        "Principal": "*",
        "Action": "s3:GetObject",
        "Resource": "<your-bucket-arn>/*"
    }
 ]
}

Also Jeeten Parmar's answer helped me too - replacing href's with routerLink's was another thing that I needed to do.

I solved this issue. I was using href that's why It was giving 404 error. I used routerLink and it solved my problem.

Are you using just straight up webpack? Or maybe Angular CLI?

You will need to build to production. Both of the above mentioned should create a dist folder when you build for production.

The src folder does not contain compiled code, so not that. And you should not be uploading the node_modules folder.

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