In an ideal scenario, we would be able to specify a custom path to a different tsconfig file in the vitest configuration. Unfortunately, I have not come across such an option.
One potential workaround that may be effective in certain cases involves using an alternate approach:
- Rather than relying on a primary
tsconfig.json
for project building and a separate tsconfig.test.json
for testing purposes,
- We can utilize the main
tsconfig.json
for editor support throughout the entire project (including tests), as well as defining test-specific configurations within it (which vitest will recognize).
- Subsequently, create a distinct
tsconfig.build.json
solely dedicated to specifying build-related settings (tsc -p ./tsconfig.build.json
)
This method enables us to control the generated build output based on parameters like rootDir
, include
, etc.