简体   繁体   English

如何阻止 VueJS S3 Deploy 重新上传静态文件?

[英]How do I stop VueJS S3 Deploy from re-uploading static files?

I'm making a new VueJS app using Vue' CLI tool, and adding a few images and fonts to the "assets" folder inside "src", however every time I do a vue-cli-service s3-deploy , it uploads everything again instead of skipping static assets.我正在使用 Vue 的 CLI 工具制作一个新的 VueJS 应用程序,并将一些图像和字体添加到“src”内的“assets”文件夹中,但是每次我执行vue-cli-service s3-deploy ,它都会上传所有内容再次而不是跳过静态资产。

What do I need to do in order to achieve this?我需要做什么才能实现这一目标?

It turned out being the dist folder itself that gets re-generated entirely when building, and that confuses AWS SYNC functionality, making it upload everything again.结果是 dist 文件夹本身在构建时完全重新生成,这混淆了 AWS SYNC 功能,使其再次上传所有内容。

I ended up splitting the deploy process into 2 different NPM tasks, one of them uploading the assets folder and the other uploading the rest.我最终将部署过程拆分为 2 个不同的 NPM 任务,其中一个上传资产文件夹,另一个上传其余的。 Here are the final commands:最后的命令如下:

1) Deploy fonts an images 1) 部署字体和图像

aws s3 sync --acl public-read dist/fonts s3://bucket/fonts
aws s3 sync --acl public-read dist/img s3://bucket/img

2) Deploy the rest of the project except my assets 2)部署项目的其余部分,除了我的资产

aws s3 sync --acl public-read --exclude 'fonts/*' --exclude 'img/*' dist s3://bucket

It's worth noting that both "img" and "fonts" folders are generated by Vue CLI itself and contain all of the project images and fonts respectively.值得注意的是,“img”和“fonts”文件夹都是由 Vue CLI 本身生成的,分别包含所有项目图像和字体。

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

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