不确定以下配置有什么问题,但由于某种原因,它不想转换我的项目的ts文件。如下所示,它在运行gulp任务时甚至不会抛出任何错误。它只是运行就好像一切都好,并且不生成任何.js文件,也没有创建构建目录。
(也在管理模式下测试,但没有运气)
当我手动运行tsc -p config/tsconfig.json
版本:
λ gulp -v
[00:13:03] CLI version 1.2.2
[00:13:03] Local version 3.9.1
+-- typescript@2.1.5
λ node -v
v6.9.4
项目目录结构:
的src /
配置/
gulpfile.js
gulpfile.js :
const gulp = require('gulp');
const del = require('del');
const tsc = require("gulp-typescript");
const sourcemaps = require('gulp-sourcemaps');
var config = {
jit: {
root: './build/jit',
index: 'index-jit.html'
},
aot: {
root:'./build/aot/dist',
index: 'index-aot.html'
}
};
gulp.task("compile:jit", () => {
let tsProject = tsc.createProject("config/tsconfig.json");
log("[JIT] Compiling all .ts files")
let tsResult = tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject());
return tsResult.js
.pipe(sourcemaps.write(".", {sourceRoot: '/src'}))
.pipe(gulp.dest(tsProject.options.outDir));
});
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"lib": [ "es2015", "dom" ],
"outDir": "../build/jit/app",
"suppressImplicitAnyIndexErrors": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"sourceMap": true,
"typeRoots": [
"../node_modules/@types/"
]
},
"include": [
"../src/**/*.ts"
],
"exclude": [
"../node_modules",
"../src/**/*-aot.ts"
]
}
运行gulp -LLLL compile:jit
[23:49:34] Using gulpfile [project_dir]/gulpfile.js
[23:49:34] Starting 'compile:jit'...
[23:49:34] [JIT] Compiling all .ts files
[23:49:34] Finished 'compile:jit' after 75 ms
答案 0 :(得分:0)
事实证明,无法处理文件导致gulp无法读取我的路径,因为它包含“非标准”路径字符。
C:/[Dev]/Project
显然,导致问题的是方括号,因为当我将项目移至C:/Project
时,一切都突然开始起作用。