Last active
November 20, 2017 06:47
-
-
Save epintos/c310c26068176d2bcd5f to your computer and use it in GitHub Desktop.
Angular Gulp S3 Deploy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'), | |
awspublish = require('gulp-awspublish'); | |
var localConfig = { | |
buildSrc: './build/**/*', | |
getAwsConf: function (environment) { | |
var conf = require('../../config/aws'); | |
if (!conf[environment]) { | |
throw 'No aws conf for env: ' + environment; | |
} | |
if (!conf[environment + 'Headers']) { | |
throw 'No aws headers for env: ' + environment; | |
} | |
return { keys: conf[environment], headers: conf[environment + 'Headers'] }; | |
} | |
}; | |
gulp.task('s3:production', ['build:production'], function() { | |
var awsConf = localConfig.getAwsConf('production'); | |
var publisher = awspublish.create(awsConf.keys); | |
return gulp.src(localConfig.buildSrc) | |
.pipe(awspublish.gzip({ ext: '' })) | |
.pipe(publisher.publish(awsConf.headers)) | |
.pipe(publisher.cache()) | |
.pipe(publisher.sync()) | |
.pipe(awspublish.reporter()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment