如何让Typescript编译器将编译好的js输出到其他目录?
2022-08-30 02:04:17
我对TypeScript相当陌生,现在我的项目结构在几个地方都有.ts文件:
app/
|-scripts/
|-app.ts
|
|-classes/
| |-classA.ts
| |-classB.ts
|
|-controllers/
| |-controllerA.ts
| |-controllerB.ts
|
|-otherStuff/
|-otherstuffA.ts
现在,当我的文件被编译时,它们被编译到.ts fles所在的同一目录中:
app/
|-scripts/
|-app.ts
|-app.js
|
|-classes/
| |-classA.ts
| |-classB.ts
| |-classA.js
| |-classB.js
|
|-controllers/
| |-controllerA.ts
| |-controllerB.ts
| |-controllerA.js
| |-controllerB.js
|
|-otherStuff/
|-otherstuffA.ts
|-otherStuffA.js
虽然我喜欢.js文件与.ts文件保持相同目录结构的方式,但我不想跟踪VCS中.js文件,因此我想将所有JavaScript文件保存在单独的目录树中(然后我可以将其添加到.gitignore),如下所示:
app/
|-scripts/
| |-app.ts
| |
| |-classes/
| | |-classA.ts
| | |-classB.ts
| |
| |-controllers/
| | |-controllerA.ts
| | |-controllerB.ts
| |
| |-otherStuff/
| |-otherstuffA.ts
|
|-js/
|-app.js
|
|-classes/
| |-classA.js
| |-classB.js
|
|-controllers/
| |-controllerA.js
| |-controllerB.js
|
|-otherStuff/
|-otherstuffA.js
是否有某个设置或选项可以告诉 TypeScript 编译器执行此操作?另外,我不确定它是否相关,但我正在使用WebStorm。