我试图让一个 gulp 监视任务(在保存时编译 TypeScript 文件)与 ProjectOpened 绑定一起运行 - 但它只是在项目打开时不会启动。
如果我在 Task Runner Explorer 中手动启动它,它工作正常。
我正在使用 ASP.NET Core 项目 (RC2),是否有任何 nuget 包或设置必须存在才能使项目打开的 gulp 任务运行?
或者一种调试它为什么不启动的方法?
包.json:
{
"version": "1.0.0",
"name": "demo-website",
"private": true,
"devDependencies": {
"gulp": "3.9.1",
"gulp-merge": "0.1.1",
"gulp-sourcemaps": "1.6.0",
"gulp-typescript": "2.13.4",
"jspm": "0.16.34",
"typescript": "1.8.10",
"typings": "^1.0.4"
},
"dependencies": { },
"jspm": {
"directories": {
"baseURL": "wwwroot"
},
"dependencies": {
"bootstrap": "github:twbs/bootstrap@^3.3.6",
"css": "github:systemjs/plugin-css@^0.1.21"
},
"devDependencies": { }
}
}
gulpfile.js:
/// <binding BeforeBuild='ts-compile' ProjectOpened='watch-files' />
var gulp = require("gulp"),
ts = require("gulp-typescript"),
merge = require("gulp-merge"),
sourcemaps = require("gulp-sourcemaps");
var webroot = "./wwwroot/";
var paths = {
tsSource: "./TypeScript/**/*.ts",
tsOutput: webroot + "compiled/"
};
var tsConfig = ts.createProject("tsconfig.json");
gulp.task("default", function () {
// place code for your default task here
});
gulp.task("ts-compile", function () {
return gulp.src([paths.tsSource, "./typings/index.d.ts"])
.pipe(sourcemaps.init())
.pipe(ts(tsConfig))
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.tsOutput));
});
gulp.task("watch-files", function () {
gulp.watch(paths.tsSource, ["ts-compile"]);
});