[英]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.