【发布时间】:2016-06-16 10:07:12
【问题描述】:
我有一个文件结构如下的项目:
package.json
webpack.config.json
tsconfig.json
src/
assets/
node_modules/
compiled/
etc/
我所有的源代码(.js 和.ts 文件的混合)都在src 中,我所有的编译输出都应该在compiled 中。我的tsconfig.json 看起来像这样:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"rootDir": "./src/",
"outDir": "./compiled/",
"allowJs": true
},
"exclude": ["node_modules"]
}
当我惊讶地运行 TSC 时,它还尝试在 compiled 目录中编译自己的编译输出,即使这在 rootDir 之外,并且由于启用了 allowJs,它几乎会无休止地重新编译自己发出的 JS,创建 compiled/compiled/compiled/compiled/ 目录。
我认为rootDir 会将要编译的文件限制到根目录。我可以将“已编译”添加到 exclude,但在 rootDir 之外还有很多其他文件夹包含 JS(其他构建工具等),所有这些都在启用 allowJs 的情况下被编译和输出。 . 我必须明确排除所有内容还是没有办法明确将编译器输入限制为src 路径?
【问题讨论】: