最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

webpack - How can I suppress the warning Add only entry points to the 'files' or 'include' prope

programmeradmin4浏览0评论

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"]
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论