npm install gulp-aws-s3-upload -S
Configurable gulp task for uploading to aws-s3 bucket
const gulp = require('gulp');
const gulpGzip = require('gulp-gzip');
const gulpFilter = require('gulp-filter');
const gulpAwsS3Upload = require('gulp-aws-s3-upload');
gulp.task(() => {
const filterGzipFiles = gulpFilter([ '**/*.{css,js}' ], { restore: true });
return gulp
.src([
'**/*'
])
.pipe(filterGzipFiles)
.pipe(gulpGzip())
.pipe(filterGzipFiles.restore)
.pipe(gulpAwsS3Upload({
onlyNew: process.NODE_ENV !== 'production',
cache: '.tmp/s3-cache.json',
headers: {
CacheControl: 'max-age=864000, s-maxage=864000, must-revalidate',
ACL: 'public-read' // don't forget this header if this files are public!
},
aws: {
key: '...',
secret: '...',
bucket: '...',
region: '...'
}
}));
});
Default: false
if true uploader will upload only new files (use cache)
Default: true
uploader additionally set header 'x-amz-acl': 'public-read'
Default: null
file path for caching file
Default: false
mode for cache
Default: {}
- required
credentials for s3 bucket.
- key: '...',
- secret: '...',
- bucket: '...',
- region: '...',
Default: ''
Default: {}