晚上,我在 VSCode 中运行多个 Gulp 任务时遇到了问题,即只有第一个任务运行,第二个任务被忽略。当我“Ctrl-Shift-B”时,这两个任务单独工作,但一起工作,nada。
两个非常简单的命令,一个将我的 Typescript 构建到 JS 中,另一个只是缩小和连接。只是普通的东西。
这是我的gulpfile.js
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var ts = require('gulp-typescript');
// Task that is used to compile the Typescript in JS
gulp.task('typescriptCompilation', function () {
return gulp.src('scripts/*.ts')
.pipe(ts({
noImplicitAny: true,
out: 'output.js'
}))
.pipe(gulp.dest('scripts'));
});
// Task that is used to minify anf concatanate the JS into one file for distribution
gulp.task('minifyAndConcat', function() {
return gulp.src('scripts/*.js') // read all of the files that are in script/lib with a .js extension
.pipe(concat('all.min.js')) // run uglify (for minification) on 'all.min.js'
.pipe(uglify({mangle: false})) // run uglify (for minification) on 'all.min.js'
.pipe(gulp.dest('dist/js')); // write all.min.js to the dist/js file
});
还有tasks.json
{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "typescriptCompilation",
"isBuildCommand": true,
"showOutput": "always"
},
{
"taskName": "minifyAndConcat",
"isBuildCommand": true,
"showOutput": "always"
}
]
}
这很可能是我错过了一些简单的事情,但我是 Gulp 的新手,我看不到它......