Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 371
MichaelS Avatar asked May 12 '15 12:05

MichaelS


People also ask

How does Tsconfig work?

The tsconfig.json file specifies the root files and the compiler options required to compile the project. JavaScript projects can use a jsconfig.json file instead, which acts almost the same but has some JavaScript-related compiler flags enabled by default.


2 Answers

You can use npm scripts for this. For example my package.json:

"scripts": {   "compile": "tsc -p . ",   "html": "cp -r ./src/public/ ./bin/public/",   "views": "cp -r ./src/views/ ./bin/views/",   "build": "npm run compile && npm run views && npm run html" } 

Here 2 scripts html and views for copying and task build runs them concurrently. In tasks.json I have next:

{     "version": "0.1.0",     "command": "npm",     "isShellCommand": true,     "showOutput": "silent",     "suppressTaskName": true,     "tasks": [         {             "taskName": "build",             "args": [                 "run",                 "build"             ]         }     ] } 

So shift+cmd+B will run npm build script.

like image 136
Iurii Perevertailo Avatar answered Sep 25 '22 22:09

Iurii Perevertailo


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

like image 30
Brocco Avatar answered Sep 26 '22 22:09

Brocco