Search code examples
typescriptvisual-studio-code

How to add a post tsc build task that copy files?


How to add another task to VSCode, that copies files from x to y, after the tsc build task?


Solution

  • You can use a task runner like gulp to accomplish this...

    You can configure vscode to run the build task below, which is dependent upon the compile task.

    var gulp = require('gulp'),
      exec = require('child_process').exec;
    
    gulp.task('build', ['compile'], function () {
      return gulp.src('./config/**/*.json')
        .pipe(gulp.dest('./dist'));
    });
    
    gulp.task('compile', function (done) {
      exec('tsc -p ./app', function (err, stdOut, stdErr) {
        console.log(stdOut);
        if (err){
          done(err);
        } else {
          done();
        }
      });
    });
    

    There is documentation about running gulp tasks via vscode here: https://code.visualstudio.com/Docs/tasks