How to add another task to VSCode, that copies files from x to y, after the tsc build task?
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With