Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript compile all ts files as a single JavaScript file in WebStorm 7

I have a lot of .ts files in my project. WebStorm build each .ts file as a js file. But I dont want that.

I have an app.ts file and all other .ts files will be build in that app.ts file. How can I do that in WebStorm 7?

There is a solution in CLI mode but how can i implement it in WebStorm?

 tsc --out app.js main.ts app.ts a.ts b.ts

Or is there a better way to do this?

ANSWER

Just added this line at Arguments section in Edit Watcher

--sourcemap $FileName$ --out your-main.js
like image 990
mrchad Avatar asked Feb 16 '14 21:02

mrchad


2 Answers

You can specify --out option in Typescript File watcher arguments, and, if 'track only root files' option is on, all ts files will be merged into a main js file (that imports them all directly or via references chain) on modifying any of them

like image 138
lena Avatar answered Sep 30 '22 12:09

lena


You could use grunt-ts which can maintain a reference.ts file for you, and point the webstorm file watcher to run your grunt task https://github.com/basarat/grunt-ts#javascript-generation-and-ordering

Disclaimer : I am one of the authors of grunt-ts.

like image 23
basarat Avatar answered Sep 30 '22 13:09

basarat