gpt4 book ai didi

typescript - 如何让 gulp-typescript 输出到与源文件相同的目录?

转载 作者:搜寻专家 更新时间:2023-10-30 20:34:17 25 4
gpt4 key购买 nike

我有以下管道

  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 路径的根来“硬编码” dest 路径。如果我的 src 路径是 app/modules/**.ts 我的 dest 路径必须是 app/modules。这限制了我使用单个根 src 路径,我不能使用同级。

我希望能够制作我的 src ['path1/**/*.ts', 'path2/**/*.ts] 并将转译后的输出写入源文件所在的同一文件夹。

最佳答案

如果你有这样的源文件:

gulp.src(['path1/**/*.ts', 'path2/**/*.ts])

比它等于:

gulp.src(['./path1/**/*.ts', './path2/**/*.ts], { base: '.' })

这意味着,您可以将目的地设置为:

gulp.dest('.')

因为这是最小的公分母。剩下的由 Gulp 完成。

关于typescript - 如何让 gulp-typescript 输出到与源文件相同的目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29505055/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com