想象一下:我已经main.ts
和sw.ts
。
我怎么编译main.ts
到js/
文件夹,并sw.ts
以root
目录?你可以给我一个例子吗?
我已经在以下页面的帮助下找到了解决方案:项目参考。
对我有用的是tsconfig.json
为每个目录创建一个新文件。之后,您应该在主目录中 使用它tsconfig.json
:
"references": [
{ "path": "PATH/TO/EACH/OTHER/TSCONFIG.JSON/FILES" }
]
最重要的是,您还必须将此选项添加到compilerOptions
每个辅助 tsconfig.json
文件的中:
"composite": true
另外,用于 "include"
指向.ts
该特定文件tsconfig.json
将要使用的每个文件:
"include": [
"./homeWork.ts",
"./myGame.ts"
]
要么
"include": [
"./*.ts" //Points to every .ts file inside that directory.
]
现在,您应该可以使用与main相同的目录中的任何这些命令一次编译所有文件tsconfig.json
:
tsc --build
;tsc -b //Alias for the above command
;tsc -w -b //Above command, including the option -w for watching changes recursively
。tsconfig.json
可能具有的每个引用。本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句