Run Gulp task before build in VS Code

Viewed 485

I have a new empty .NET Core project. Can I automatically run Gulp tasks before a build in VS Code?

I can run the styles task manually by doing VS Code package manager -> Tasks: Run Task -> gulp -> gulp: styles, but when I do build it does not run.

/// <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));
});

I got this code from some tutorials online and everything works except the first line.

Is this supposed to work in VS Code or is this only a luxury of Visual Studio?

1 Answers

//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
});

Read this document : Gulp for Beginners

Related