Created
October 16, 2015 16:52
-
-
Save simov/69422cdb134c2862b16d to your computer and use it in GitHub Desktop.
Gulpfile + Babel + Sourcemaps
This file contains 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 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