【问题标题】:TSconfig: compile a new js folder for each ts folderTSconfig:为每个ts文件夹编译一个新的js文件夹
【发布时间】:2019-10-29 08:03:26
【问题描述】:

我想为每个脚本文件夹编译一个新的 js 文件夹。 tsconfig.json 有可能吗?

目录

folder1
  scripts
    index.ts

folder2
  scripts
   index.ts
tsconfig.json

编译后的目录

folder1
  scripts
    index.ts
  js
    index.js

folder2
  scripts
    index.ts
  js
    index.js
tsconfig.json

【问题讨论】:

  • 现在我正在为每个目录使用tsconfig.json 文件...编辑:不,那没有用...

标签: javascript typescript compilation tsconfig


【解决方案1】:

免责声明...这并没有具体回答您的问题,因为您想做的事情违反了惯例。即使你设法按照自己的方式去做,我想你也会发现痛苦大于好处。

最简单的方法是指定一个outDir 输出目录。您现有的文件夹结构将保留在输出目录中,所有 JavaScript 和 TypeScript 都保持干净分离。

{
    "compilerOptions": {
        "outDir": "./scripts",
        ...
    }
}

所以如果你开始:

/component-a
    index.ts
/component-b
    index.ts

您最终会得到在输出目录中镜像的文件夹。

/component-a
    index.ts
/component-b
    index.ts
/scripts
    /component-a
        index.js
    /component-b
        index.js

除非您计划同时部署(?)您通常不希望 TypeScript 和 JavaScript 混合。

【讨论】:

  • 有没有办法不在我的js 文件夹中获取scripts 文件夹。当我编译它看起来像这样:/js/folder1/scripts/index.js;我希望它看起来像这样:/js/folder1/index.js;
猜你喜欢
  • 1970-01-01
  • 2020-07-30
  • 1970-01-01
  • 1970-01-01
  • 2019-05-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多