在 VS Code 中构建之前运行 Gulp 任务

Kid*_*lly 5 less gulp visual-studio-code asp.net-core

我有一个新的空 .NET Core 项目。我可以在 VS Code 中构建之前自动运行 Gulp 任务吗?

我可以styles通过执行手动运行任务VS Code package manager -> Tasks: Run Task -> gulp -> gulp: styles,但是当我构建它时它不会运行。

/// <binding beforebuild="styles"></binding>

var gulp = require('gulp');
var gulpless = require('gulp-less');

gulp.task('styles', function () {
    var srcfile = 'styles/Styles.less';
    var dest = 'wwwroot';
    return gulp
        .src(srcfile)
        .pipe(gulpless())
        .pipe(gulp.dest(dest));
});
Run Code Online (Sandbox Code Playgroud)

我从一些在线教程中得到了这段代码,除了第一行之外,一切正常。

这应该在 VS Code 中工作还是只是 Visual Studio 的奢侈品?

小智 0

\r\n
\r\n
//In this case we\xe2\x80\x99re adding the a task before other task.\n\ngulp.task(\'watch\', [\'array\', \'of\', \'tasks\', \'to\', \'complete\',\'before\', \'watch\'], function (){\n  // ...\n})\n\n\n//And in this case we\xe2\x80\x99re adding for example the browserSync task.\n\ngulp.task(\'watch\', [\'browserSync\'], function (){\n  gulp.watch(\'app/scss/**/*.scss\', [\'sass\']); \n  // Other watchers\n})\n\n\n//We\xe2\x80\x99ll also want to make sure sass runs before watch so the CSS will already be the latest whenever we run a Gulp command.\n\ngulp.task(\'watch\', [\'browserSync\', \'sass\'], function (){\n  gulp.watch(\'app/scss/**/*.scss\', [\'sass\']); \n  // Other watchers\n});
Run Code Online (Sandbox Code Playgroud)\r\n
\r\n
\r\n

\n

\n

阅读此文档:Gulp 初学者

\n
\n