how to nominate typescript compiler output

With Webstorm tracking changes in the source typescript files and using the bundled compiler, how can I have the compiled files be written written to another directory relative to the source file.

 

for example the source in modules/foo/bar.ts outputs to www/app/foo/bar.js

and modules/foo2/bar2.ts outputs to www/app/foo2/bar2.js

 

 

3 comments

Possible using tsconfig.json.
There are 2 possible solutions:

  • create tsconfig.json in your 'modules' folder:
{
  "compilerOptions": {
    "target": "es5",
    "declaration": false,
    "outDir": "../www/app",
    "sourceMap": true
  }
}
  • or, create it in your project root directory:
{
  "compilerOptions": {
    "target": "es5",
    "declaration": false,
    "outDir": "./www/app",
    "rootDir": "./modules",
    "sourceMap": true
  }
}

Then, enable 'Use tsconfig.json' in TypeScript compiler settings

0

I have two tsconfig.json files in the project and the tsconfig that I do not want to use is discovered by webstorm.

Can this situation be fixed?

0

WebStorm behaves as designed: it uses the tsconfig nearest to current file when transpiling your code. 

If you don't like using multiple files, you can pass '--project' (or just '-p') command line option that specifies the path of a directory containing a tsconfig.json file to compiler. But you would need using 'set options manually' option then

0

Please sign in to leave a comment.