Last active
June 13, 2019 05:55
-
-
Save rwev/3cb732af74e1377a2037568b760fda7e to your computer and use it in GitHub Desktop.
Grunt configuration for on-change compilation and execution TypeScript files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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