【发布时间】:2015-10-08 14:48:39
【问题描述】:
我的项目中有这样的文件夹结构:
- 常见
- 游戏
- 游戏1
- 游戏2
- ...
每个文件夹都包含一个 Typescript 文件列表,所有游戏都依赖于 Common 文件夹。
使用 Typescript 编译所有内容大约需要 10 秒。是否可以创建一个单独观看每场比赛的 gulp-watch?
这就是我现在的工作:
// Compile
gulp.task('compile-games', ['clean-games'], function () {
var folders = getFolders(inputPaths.games);
var gameTasks = folders.map(function (folder) {
return gulp.src([
path.join(inputPaths.common, '/**/*.ts'),
path.join(inputPaths.games, folder, '/**/*.ts')], { base: inputPaths.scripts })
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(typescript({
target: "ES5",
noImplicitAny: false,
sortOutput: true
}))
.pipe(concat('Game.js'))
.pipe(sourcemaps.write('./', { includeContent: true, debug: true }))
.pipe(gulp.dest(path.join(outputPaths.games, folder)));
});
// Watches
gulp.task('watch', function () {
gulp.watch(path.join(inputPaths.games, "**/*.ts"), ["compile-games"]);
gulp.watch(path.join(inputPaths.common, "**/*.ts"), ["compile-games"]);
});
【问题讨论】:
标签: typescript gulp gulp-watch