Skip to content

Instantly share code, notes, and snippets.

@rwev
Last active June 13, 2019 05:55
Show Gist options
  • Save rwev/3cb732af74e1377a2037568b760fda7e to your computer and use it in GitHub Desktop.
Save rwev/3cb732af74e1377a2037568b760fda7e to your computer and use it in GitHub Desktop.
Grunt configuration for on-change compilation and execution TypeScript files.
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON(
'package.json'),
watcher: {
options: {
dateFormat: function(
time) {
grunt.log
.writeln(
`Finished in ${time} ms. Watching...`
.yellow
.bold
);
},
},
scripts: {
files: ['**/*.ts',
'!/node_modules/**'
],
tasks: ['exec'],
options: {
spawn: false,
interrupt: true
}
}
},
exec: {
tsc: {
command: []
}
}
});
grunt.loadNpmTasks('grunt-watcher');
grunt.loadNpmTasks('grunt-exec');
grunt.event.on('chokidar', function(action, filepath) {
grunt.config('exec.tsc.command',
'ts-node ' + filepath);
});
grunt.registerTask('default', ['watcher']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment