Skip to content

Instantly share code, notes, and snippets.

@arackaf
Created December 23, 2015 21:01
Show Gist options
  • Save arackaf/bdb4dcb39c5e6010a94e to your computer and use it in GitHub Desktop.
Save arackaf/bdb4dcb39c5e6010a94e to your computer and use it in GitHub Desktop.
gulp.task('transpile', function() {
return gulp.watch('**/**-es6.js', function(obj){
if (obj.type === 'changed') {
gulp.src(obj.path, { base: './' })
.pipe(plumber({
errorHandler: function (error) {
//babel error - dev typed in in valid code
if (error.fileName) {
var fileParts = error.fileName.split('\\');
try {
notify.onError(error.name + ' in ' + fileParts[fileParts.length - 1])(error);
} catch(e) {} //gulp-notify may break if not run in Win 8
console.log(error.name + ' in ' + error.fileName);
} else{
notify.onError('Oh snap, file system error! :(')(error);
}
console.log(error.message);
this.emit('end');
}
}))
.pipe(babel({ presets: ['babel-preset-es2015'], plugins: ['syntax-decorators', 'transform-decorators'] }))
.pipe(rename(function (path) {
path.basename = path.basename.replace(/-es6$/, '');
}))
.pipe(gulp.dest(''))
.pipe(gprint(function(filePath){ return "File processed: " + filePath; }));
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment