gulp.task('build:server:js', function(){
return gulp.src("server/**/*.js")
.pipe(sourcemaps.init())
.pipe(babel({
"presets": ["es2015", "react", "stage-0"]
}))
.pipe(sourcemaps.write('.', {
includeContent: false,
sourceRoot: function(file) {
var from = file.path;
var to = path.resolve(__dirname+'/../server');
var dest = path.relative(from, to) + '/../server';
console.log("from %s\nto: %s\ndest: %s\n", from, to, dest);
return dest;
}
}))
.pipe(gulp.dest("dist/server/"));
});
gulp 任务在./tasks
文件夹中,而不是./
- 构建是在./dist
文件夹中生成的,应该指向./path/to/src.js
.
dist 文件夹与根项目文件夹具有相同的结构。(即:./server/core/routes.js
例如./dist/server/core/routes.js
,与.maps
文件一起编译时最终会出现。