1
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文件一起编译时最终会出现。

4

0 回答 0