Skip to content

Instantly share code, notes, and snippets.

@simov
Created October 16, 2015 16:52
Show Gist options
  • Save simov/69422cdb134c2862b16d to your computer and use it in GitHub Desktop.
Save simov/69422cdb134c2862b16d to your computer and use it in GitHub Desktop.
Gulpfile + Babel + Sourcemaps
var path = require('path')
var gulp = require('gulp')
var sourcemaps = require('gulp-sourcemaps')
var babel = require('gulp-babel')
var paths = {
es6: ['**/*.js', '!gulpfile.js', '!build/**/*.*'],
es5: 'build',
// must be absolute or relative to source map
sourceRoot: path.join(__dirname)
}
gulp.task('babel', function () {
return gulp.src(paths.es6)
.pipe(sourcemaps.init())
.pipe(babel({
optional: [
'es7.asyncFunctions',
'es7.exportExtensions'
]
}))
.pipe(sourcemaps.write('.', {sourceRoot: paths.sourceRoot}))
.pipe(gulp.dest(paths.es5))
})
gulp.task('watch', function () {
gulp.watch(paths.es6, ['babel'])
})
gulp.task('default', ['watch'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment