admin管理员组

文章数量:1353186

When building my NX Angular application I include **/env**.ts in tsconfig.app.json. I do this to compile all env files. However I determine which ones will be used in webpack.config.ts. I add files like env.qa.ts as entry points depending on some logic. So basically I don't know what env.x.ts will or will not be part of the build until webpack does its work. This leads to the warning, "is part of the TypeScript compilation but it's unused. Add only entry points to the 'files' or 'include' properties in your tsconfig."

I can't simply exclude the env files as I don't know which ones I will need until webpack completes. My project actually has hundreds of env.ts files, so this warning comes up a lot. Please let me know if there is some way to suppress this warning.

I tried setting warnings to false in webpack config.stats.warnings. That didn't work. I can't seem to find a suppression flag or a work around.

tsconfig.app.json

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "../../dist/out-tsc",
    "types": ["node", "jest"],
    "target": "ES2022",
    "useDefineForClassFields": false
  },
  "files": ["src/main.ts", "src/polyfills.ts"],
  "include": ["**/*.d.ts", "**/env**.ts"],
  "exclude": ["**/*.spec.ts", "**/*.mock.ts", "**/e2e", "**/testing", "jest.config.ts"]
}

本文标签: