我正在开发一个打印脚本项目,我需要为其创建两个不同的JS捆绑软件包,一个用于管理员包,另一个用于其他包,并为每个捆绑包生成源映射。我一直试图从gulp-typescript中克隆js流,然后过滤出与捆绑相关的文件,然后合并这些流并编写源地图。但是,在运行任务后,不会创建捆绑软件。gulp-typescript with multiple bundles and sourcemaps
gulpfile.js
var config = {
src: {
ts:['./Content/Scripts/TypeScript/**/*.ts']
},
bundles: {
dashboard: [
'**/Controller/Widgets/**/*.js',
'**/Services/Widgets/**/*.js'
],
core: [
'**/Common/**/*.js',
'**/Server/**/*.js',
'**/Controller/Search/**/*.js'
]
}
}
gulp.task('build-ts', function() {
var tsResult = gulp.src(config.src.ts)
.pipe(srcMap.init())
.pipe(tsProj());
var bundleStreams = [
tsResult.js
.pipe(clone())
.pipe(filter(config.bundles.core))
.pipe(concat(config.outFiles.bundles.core)),
tsResult.js
.pipe(clone())
.pipe(filter(config.bundles.dashboard))
.pipe(concat(config.outFiles.bundles.dashboard))
];
return merge([
merge(bundleStreams)
.pipe(srcMap.write())
.pipe(gulp.dest(config.dist.main)),
tsResult.dts
.pipe(concat(config.outFiles.typeDef))
.pipe(gulp.dest(config.dist.main))
]);
});
的package.json
{
"devDependencies": {
"gulp": "^3.9.1",
"gulp-clone": "^1.0.0",
"gulp-concat": "^2.6.1",
"gulp-filter": "^5.0.0",
"gulp-sourcemaps": "^2.4.1",
"gulp-typescript": "^3.1.4",
"merge2": "^1.0.3",
"typescript": "2.2.1"
},
}
注:源打字稿文件正在使用的命名空间不会模块。
感谢您的建议,理想情况下,我只会喜欢调用'一次tsc'但它有一个好的备份 –