【问题标题】:Compiling all TypeScript files in project and maintaining file structure编译项目中的所有 TypeScript 文件并维护文件结构
【发布时间】:2016-03-06 08:05:03
【问题描述】:

我想使用某种任务运行程序(Grunt、Gulp 等)将同一文件夹(项目)内不同位置的 TS 文件编译为 JS 文件。输出的 JS 文件必须输出到同一个目录下,项目会在 TS 文件所在的位置搜索这些 JS 文件。

例子:

lib/**/*.ts
workspace/**/*.ts

我曾尝试使用 Grunt 和 Gulp,但它们似乎不允许在整个项目文件夹中递归搜索任何 .ts 文件,这是这里的主要问题。

【问题讨论】:

  • 从 JS 到 TS?我认为这是不可能的......
  • TS 到 JS ofc,我的错 :)

标签: javascript typescript gruntjs gulp


【解决方案1】:

您必须在 tsConfig.json 或 gulp typescript 配置中指定 outDir。

例如:

{
    "compilerOptions": {
        "module": "system",
        "target": "es5",
        "noImplicitAny": false,
        "sourceMap": true,
        "outDir": "./build"
    },
    "exclude": [
        "node_modules"
    ]
}

【讨论】:

    猜你喜欢
    • 2018-11-23
    • 2013-03-29
    • 2012-06-18
    • 2016-12-13
    • 2014-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-02
    相关资源
    最近更新 更多