[英]Intellij Idea - compiling Typescript to Javascript and keeping directory structure
I'm trying to get Intellij Idea to keep the directory structure when compiling Typescript to Javascript. 我正在尝试让Intellij Idea保留将Typescript编译为Javascript时的目录结构。 My directory structure is as follows: 我的目录结构如下:
root
- ts
- SomeClass1.ts
- SomeFolder
- AwesomeClass2.ts
- tsc
I want the resulting compiled files to be: 我希望生成的编译文件为:
root
- tsc
- SomeClass1.js
- SomeFolder
- AwesomeClass2.js
This is my Typescript configuration: 这是我的Typescript配置:
However when trying to compile, I'm getting this error in the console: 但是,当尝试编译时,我在控制台中收到此错误:
Create tsconfig.json in the root directory: 在根目录中创建tsconfig.json:
{
"compilerOptions": {
"module": "amd",
"target": "es5",
"outDir": "tsc",
"rootDir": "ts",
"sourceMap": true,
"declaration": true
},
"exclude": [
"tsc"
]
}
and enable "use tsconfig.json" in IntelliJ. 并在IntelliJ中启用“ use tsconfig.json”。
If you use tsconfig.json
you can specify the rootDir
and outDir
, if you do that then it will keep the directory structure of the rootDir
in the compiled version inside the outDir
. 如果你使用tsconfig.json
可以指定rootDir
和outDir
,如果你这样做,那么它将保持的目录结构rootDir
在内部编译版本outDir
。
In your case: 在您的情况下:
{
"compilerOptions": {
"outDir": "tsc",
"rootDir": "ts",
"sourceMap": true,
"declaration": true
}
}
Place this file as tsconfig.json
in your root
directory and in intellij/webstorm Enable Typescript Compiler
and then Use tsconfig.json
. 将此文件作为tsconfig.json
放在您的root
目录中,并在intellij / webstorm Enable Typescript Compiler
,然后Use tsconfig.json
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.