s3-deploy for vue-cli
This vue-cli plugin aims to make it easier to deploy a built Vue.js app to an S3 bucket.
- Custom AWS regions
- Support for AWS credential profiles
- Concurrent uploads for improved deploy times
- CloudFront distribution invalidation
Cache-Controlmetadata for use with PWAs and Service Workers
- Configurable paths for multiple Vue apps in a single bucket
You must have a set of valid AWS credentials set up on your system.
yarn add vue-cli-plugin-s3-deploy
After installation, invoke the plugin with
vue invoke s3-deploy.
Answer the configuration prompts. This will inject a
deploy script command into your
Deploy your app with
Options are set in
vue.config.js and overridden on a per-environment basis by
region: "AWS region for the specified bucket (default: us-east-1)"bucket: "The S3 bucket name (required)"assetPath: "The path to the built assets (default: dist)"deployPath: "Path to deploy the app in the bucket (default: /)"uploadConcurrency: "The number of concurrent uploads to S3 (default: 3)"pwa: "Sets max-age=0 for the PWA-related files specified"enableCloudfront: "Enables support for Cloudfront distribution invalidation"cloudfrontId: "The ID of the distribution to invalidate"cloudfrontMatchers: "A comma-separated list of paths to invalidate (default: /*)"
pwa option is meant to help make deploying progressive web apps a little easier. Due to the way service workers interact with caching, this option alone will tell the browser to not cache the
service-worker.js file by default. This ensures that changes made to the service worker are reflected as quickly as possible.
You can specify which files aren't cached by setting a value for the
Deployment options can be overridden with .env files to support development, staging, and production deployment environments.
The .env file options are, with examples:
These options OVERRIDE the config options set in vue.config.js and should be used to customize a default set of options. A common use case is only overriding
VUE_APP_S3D_BUCKET for production deployment.
Specifying AWS Credentials
The AWS SDK will pick up the default credentials from your
~/.aws/credentials file and it will pick up credentials from the environment variables
To specify credentials other than
~/.aws/credentials, change the command in
"deploy": "AWS_PROFILE=other-profile-name vue-cli-service s3-deploy"
- Rollback crendential selection via
awsProfile. The SDK supports this via the
deployPathoption. Allows you to deploy to folder in the bucket, not always to the root. Fixes #15.
awsProfilefor using AWS credentials other than
default. Fixes #19.
- Fixed #12: paths were built naively and broke deployment on Windows platforms.
- Fixed bug where deployment crashes if you declined Cloudfront on initial invocation.
- Added support for invalidating Cloudfront distributions on deploy.
- Refactored how the configuration is stored and brought it more inline with vue cli standards. All config is in vue.config.js now.
- Updated the dependency on vue-cli to 3.0.0-rc3
- Squashed a few bugs along the way
- Added support for .env files and per-environment options
- Added parallel uploading
- Initial Release
Contributions welcome. Just open a pull request.