How to exclude specific files in typescript only for the build?

One possible solution would be to use two different tsconfig files, one for the tests and one for the production build.

tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "outDir": "./build",
    "baseUrl": ".",
    "paths": {
      "*": ["types/*"]
    },
    "strict": true,
  }
}

tsconfig.prod.json

{
  "extends": "./tsconfig",
  "exclude": ["**/*.test.ts", "**/*.mock.ts"]
}

Then point tsc to the new config when running tsc -p tsconfig.prod.json

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)