How to add a post tsc build task that copy files?
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
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.