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



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

我可以通过执行VS Code package manager -> Tasks: Run Task -> gulp -> gulp: styles手动运行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));
});

我从网上的一些教程中得到了这段代码,除了第一行外,其他一切都正常工作。

这应该在VS代码中工作吗?还是这只是Visual Studio的一种奢侈?

//In this case we’re adding the a task before other task.
gulp.task('watch', ['array', 'of', 'tasks', 'to', 'complete','before', 'watch'], function (){
// ...
})

//And in this case we’re adding for example the browserSync task.
gulp.task('watch', ['browserSync'], function (){
gulp.watch('app/scss/**/*.scss', ['sass']); 
// Other watchers
})

//We’ll also want to make sure sass runs before watch so the CSS will already be the latest whenever we run a Gulp command.
gulp.task('watch', ['browserSync', 'sass'], function (){
gulp.watch('app/scss/**/*.scss', ['sass']); 
// Other watchers
});

阅读此文档:Gulp for Beginners

最新更新