I want to debug a node app that runs from babel
compiled ES6 files. I have my ES6 source in an src
folder and the babel ES5 equivalent in a b
@mockaroodev solution will work only if you have a flat hierarchy in source. If you have sources in different subpaths, an absolute path (from the domain root) pointing to the source file root is recommended for sourceRoot option.
Updated gulp babel task:
var gulp = require('gulp'),
sourcemaps = require('gulp-sourcemaps'),
babel = require('gulp-babel'),
gutil = require('gulp-util'),
path = require('path');
// Compile ES6 to ES5
gulp.task("babel", function () {
return gulp.src('**/*.js')
.pipe(sourcemaps.init())
.pipe(babel())
.on('error', gutil.log)
.pipe(sourcemaps.write('.', {
includeContent: false,
sourceRoot: function(file) {
return path.relative(file.path, __dirname);
}
}))
.pipe(gulp.dest('dist'));
});