【问题标题】:Angular 2 - tsconfig outDirAngular 2 - tsconfig outDir
【发布时间】:2017-07-01 05:04:08
【问题描述】:

我目前正在开发一个 Angular2 应用程序,我面临以下问题 - 我的项目中有一些单元测试,我不希望它们与我的其他代码一起发送到 /dist 文件夹。我的项目结构如下:

dist/
 -app (compiled from src/app)
 -test (compiled from src/test)
src/
 -app
 -test

现在,我使用 tsconfig.json 中的“outDir”将所有 .js 文件编译到 /dist 目录。我想要做的只是编译所有 app/ts 文件并将它们发送到 /dist 目录,但将编译后的 .js 文件从我的 /test 目录保留在那里。它应该是这样的:

dist/
 -app (compiled from src/app)
src/
 -app
 -test ( all compiled js files remain here )

有什么想法吗?

谢谢

【问题讨论】:

    标签: angular typescript tsc tsconfig


    【解决方案1】:

    您可以尝试以下方法:

    - src/
      - app/
      - test/
        - tsconfig.json
      - tsconfig.json
    

    tsconfig.jsonsrc/

    {
      "compilerOptions": {
        "outDir": "../dist"
        [...]
      },
      "exclude": [],
      "include": ["./app"]
      [...]
    }
    

    tsconfig.jsontest/

    {
      "compilerOptions": {
        "outDir": "./"
        [...]
      },
      "extends": "../tsconfig.json",
      "include": ["./"]
      [...]
    }
    

    小心编译你的代码,你必须运行两次tsc

    • src 文件夹,编译您的应用程序代码。

    • test 文件夹,编译您的测试。

    【讨论】:

      猜你喜欢
      • 2016-05-18
      • 1970-01-01
      • 2018-07-26
      • 1970-01-01
      • 2023-03-18
      • 2013-04-07
      • 2019-04-09
      • 2021-07-21
      • 1970-01-01
      相关资源
      最近更新 更多