我怎样才能让gulp-typescript输出到源文件所在的目录? [英] How can I get gulp-typescript to output to the same directory as the source file?
问题描述
我有以下流水线:
$ b
I have the following pipeline
function typescripts() {
return gulp.src(paths.watchedFiles.ts)
.pipe(cached('typescripts'))
.pipe(plumber())
.pipe(addsrc(paths.ts.include))
//TODO: Need to eliminate the original source path (ex. /users/userName) from the sourcemap file.
.pipe(sourcemaps.init())
.pipe(ts(tsProjectMode, undefined, ts.reporter.fullReporter(true))).js
.pipe(gulpIgnore.exclude(paths.ts.excludeFromPostCompilePipeline))
.pipe(ngAnnotate({
remove: false,
add: true,
gulpWarnings: false //typescript removes base path for some reason. Warnings result that we don't want to see.
}))
.pipe(sourcemaps.write('.', {includeContent: false}))
.pipe(gulp.dest(paths.ts.basePath));
}
我似乎不得不根据src路径的根。如果我的src路径是 app / modules / **。ts
,我的dest路径必须是 app / modules
。这限制了我使用单根src路径,我不能使用兄弟。
I seem to have to make "hard code" the dest path based on the root of the src path. If my src path is app/modules/**.ts
my dest path must be app/modules
. This limits me to using a single root src path and I cannot use siblings.
我希望能够使我的src ['path1 /**/*.ts','path2 / ** / * .ts]
,并将转码后的输出写入源文件所在的同一文件夹。
I would like to be able to make my src ['path1/**/*.ts', 'path2/**/*.ts]
and have the transpiled output written to the same folder where the source file was located.
推荐答案
如果您有类似的源文件:
If you have source files like that:
gulp.src(['path1/**/*.ts', 'path2/**/*.ts])
与它相同:
Than it's equal to that:
gulp.src(['./path1/**/*.ts', './path2/**/*.ts], { base: '.' })
这意味着,您可以将您的目的地设为:
Which means, you can put your destination to:
gulp.dest('.')
因为这是最低的共同点。其余的由Gulp完成。
since that's the lowest common denominator. The rest is done by Gulp.
这篇关于我怎样才能让gulp-typescript输出到源文件所在的目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!