hexo-deployer-s3-cloudfront
Amazon S3 and Cloudfront deployer plugin for Hexo. Based on Josh Strange's orginial plugin.
Installation
$ npm install hexo-deployer-s3-cloudfront --save
Usage
Add the plugin in the plugins list in _config.yml
:
- hexo-deployer-s3-cloudfront
and configure the plugin in the same file with:
# You can use this:deploy:type: s3-cloudfrontbucket: <S3 bucket>aws_key: <AWS id key> // Optional, if the environment variable `AWS_KEY` is setaws_secret: <AWS secret key> // Optional, if the environment variable `AWS_SECRET` is setconcurrency: <number of connections> // Optionalforce_overwrite: <true/false> // Optional: If existing files should be forcefully overwritten on S3. Default: trueregion: <region> // Optional, default: us-standardcf_distribution: <cloudfront distribution> // Optional: Which distribution should be invalidated?headers: <headers in JSON format> // pass any headers to S3, usefull for metadata cache setting of Hexo assets
Example: header Cache-Control
deploy:type: s3-cloudfrontbucket: my-site-bucketcf_distribution: mydistributionidheaders: {CacheControl: 'max-age=604800, public'}
This will set "Cache-Control" header in every file deployed to max-age 1 week. This solves "Leverage browser caching" on most page speed analyzers. For custom metadata use:
headers: {Metadata : { x-amz-meta-mykey: "my value" }}
Contributors
- Wouter van Lent (wouter33)
- Josh Strange (joshstrange; original implementation)
- Josenivaldo Benito Jr. (JrBenito)
License
MIT