【问题标题】:Typescript compiler not saved json in root directoryTypescript编译器未将json保存在根目录中
【发布时间】:2021-11-12 09:03:33
【问题描述】:

我在 express/typescript 和我的根目录后端有一个项目,文件 .json 不保存在文件夹 dist 中

tsconfig.json

{


"compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es6",
    "moduleResolution": "node",
    "sourceMap": true,
    "outDir": "dist",
    "resolveJsonModule": true
  },
  "lib": ["es2015"]
}

tslint.json

  {
    "defaultSeverity": "error",
    "extends": ["tslint:recommended"],
    "jsRules": {},
    "rules": {
      "no-console": false
    },
    "rulesDirectory": []
  }

根目录

  • appsettings.development.json -> 此文件未保存在 dist 文件夹中
  • appsettings.json -> 此文件未保存在 dist 文件夹中
  • swagger.json -> 这个文件没有保存在 dist 文件夹中
  • tsconfig.json
  • tslint.json
  • 分布

目录顺序:

【问题讨论】:

标签: node.js typescript express


【解决方案1】:

我认为这是它应该做的。你在 tsconfig.json 上放的任何东西都会被 Typescript 编译器使用,它将 ts 文件编译成 js。它对其他文件没有任何作用。

tslint.json 与你的问题无关,它是用来设置 linting 规则的。

您想要实现的目标通常是通过使用一些 shell 命令(如“cp”)或使用捆绑器(如 webpack、rollup 等)扩展您的 npm 脚本来完成。

【讨论】:

    猜你喜欢
    • 2018-04-14
    • 1970-01-01
    • 2020-07-02
    • 1970-01-01
    • 2017-07-15
    • 1970-01-01
    • 2020-06-04
    • 2011-11-25
    • 1970-01-01
    相关资源
    最近更新 更多