Skip to content

Instantly share code, notes, and snippets.

@bkw
Last active August 29, 2015 14:10
Show Gist options
  • Save bkw/3dd96f05656a7e102e74 to your computer and use it in GitHub Desktop.
Save bkw/3dd96f05656a7e102e74 to your computer and use it in GitHub Desktop.
var gulp = require('gulp')
, jade = require('gulp-jade')
, rename = require('gulp-rename')
, minifyHTML = require('gulp-minify-html')
, minifyInline = require('gulp-minify-inline')
, zopfli = require('gulp-zopfli')
, AWS = require('aws-sdk')
, through2 = require('through2')
, aws = new AWS.S3({accessKeyId: 'key', secretAccessKey: 'secret', region: 'eu-central-1'})
, s3 = require('vinyl-s3')(aws, {
Bucket: 'mybucket',
CacheControl: 'max-age:86400, no-transform, public',
ContentType: 'text/html',
ContentEncoding: 'gzip'
})
;
gulp.task('html', function () {
gulp.src('./views/index.jade')
.pipe(jade({locals: {foo: 'bar'}))
.pipe(minifyInline())
.pipe(minifyHTML())
.pipe(zopfli())
.pipe(rename({basename: 'index', extname: '.html'}))
.pipe(through2.obj(function(file, _, callback) {
file.contentType = 'text/html';
this.push(file);
callback();
}))
.pipe(s3.dest('somedir'))
});
gulp.task('default', ['html']);
@bkw
Copy link
Author

bkw commented Nov 30, 2014

expected result: upload to s3 bucket mybucket as somedir/index.html .
Actual result: somedir/ndex.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment