kretschmann.cat/gulpfile.js

43 lines
1.1 KiB
JavaScript

'use strict';
var gulp = require('gulp'),
awspublish = require('gulp-awspublish')
// paths
var DIST = './site/';
// deployment
var S3BUCKET = 'kretschmann.cat',
S3REGION = 'eu-central-1';
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Deployment
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gulp.task('deploy', function() {
// create publisher, define config
var publisher = awspublish.create({
params: {
'Bucket': S3BUCKET
},
'accessKeyId': process.env.AWS_ACCESS_KEY,
'secretAccessKey': process.env.AWS_SECRET_KEY,
'region': S3REGION
});
// define custom headers
var headers = {
'Cache-Control': 'max-age=315360000, no-transform, public'
};
return gulp.src(DIST + '**/*')
.pipe(publisher.publish(headers))
.pipe(publisher.sync()) // delete files in bucket that are not in local folder
.pipe(publisher.cache())
.pipe(awspublish.reporter({
states: ['create', 'update', 'delete']
}));
});