grunt で監視して typescriptを自動コンパイル
https://www.npmjs.com/package/grunt-typescript
$ npm install grunt-typescript –save
referenceも各ファイルに書かずに済んで良い感じです
Gruntfiles.js
module.exports = function(grunt) {
grunt.initConfig({
cssmin: {
minify: {
files: {
}
}
},
typescript: {
base: {
src: ['src/typescript/**/*.ts'],
dest: 'src/javascript',
options: {
module: 'commonjs',
target: 'es5',
basePath: 'src/typescript',
references: [
'typings/tsd.d.ts'
],
watch: 'src/typescript'
}
}
}
}
grunt.loadNpmTasks('grunt-typescript');
};
監視開始
$ grunt typescript
Running "typescript:base" (typescript) task
Watching... src/typescript
change src/typescript/routes/index.ts
1 file created. js: 1 file, map: 0 files, declaration: 0 files (1795ms)
ファイルが出来ました。
$ tree src/typescript/
src/typescript/
└── routes
└── index.ts
$ tree src/javascript/
src/javascript/
└── routes
└── index.js