简体   繁体   English

在AWS S3上部署Angular 2应用程序

[英]Deploy Angular 2 app on AWS S3

How to deploy Angular 2 app on aws s3 ? 如何在aws s3上部署Angular 2应用程序? Do I need to upload only src folder or with node_modules ? 我是否只需要上传src文件夹或node_modules Is there anything I need to do with my code ? 我的代码有什么需要做的吗?

I have aws panel to upload files through browse. 我有aws面板通过浏览上传文件。 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 其他人看到这个问题 - >首先看看: 如何将Angular应用程序捆绑生产它基本上就是说要运行

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: 之后,只需将您的dist文件夹上传到一个S3存储桶,该存储桶在存储桶的属性选项卡中启用了“静态虚拟主机”,并为其提供一个存储桶策略,允许每个人从中获取类似于:

{
"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. Jeeten Parmar的回答也帮助了我 - 用routerLink取代href是我需要做的另一件事。

I solved this issue. 我解决了这个问题。 I was using href that's why It was giving 404 error. 我正在使用href这就是为什么它给出了404错误。 I used routerLink and it solved my problem. 我使用了routerLink ,它解决了我的问题。

Are you using just straight up webpack? 您是否直接使用webpack? Or maybe Angular CLI? 或者Angular CLI?

You will need to build to production. 你需要建立生产。 Both of the above mentioned should create a dist folder when you build for production. 当你为生产构建时,上面提到的两个都应该创建一个dist文件夹。

The src folder does not contain compiled code, so not that. src文件夹不包含已编译的代码,因此不包含。 And you should not be uploading the node_modules folder. 而且您不应该上传node_modules文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 AWS S3 + Cloudfront 上更新 Angular 应用程序 - Update Angular app on AWS S3 + Cloudfront 如何部署基于Angular2 Typescript的应用程序是AWS S3 - how to deploy an Angular2 Typescript based application is AWS S3 如何使用 AWS CloudFront S3 Lambda 部署 Angular 通用应用程序而不是运行 EC2 服务器? - How can I deploy Angular Universal App with AWS CloudFront S3 Lambda instead of running a EC2 server? 使用AWS S3和CodePipeline自动执行Angular 7 App部署 - Automating Angular 7 App Deployment with AWS S3 and CodePipeline 使用代理在 AWS S3 存储桶中托管 Angular 6 应用程序 - Hosting a Angular 6 app in AWS S3 bucket with proxy 在AWS的S3中托管的角度应用程序中使用发布方法 - Using Post Method in angular app hosted in S3 in AWS 使用代码管道在 AWS S3 上部署 Angular 7 应用程序时出错 - Error while deploying Angular 7 app on AWS S3 using codepipeline 将新版本的 Angular 应用程序部署到 AWS S3 - Deploying new versions of Angular App to AWS S3 AWS Codepipeline 使用 --delete 标志部署到 S3 - AWS Codepipeline Deploy to S3 with a --delete flag 如何将 Angular 仅前端应用程序部署到使用 Jhipster 生成的 AWS(S3 或任何其他)? - How to deploy Angular front end only application to AWS (S3 or any other) generated using Jhipster?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM