A partial tsconfig object containing compilerOptions.paths
The root directory used to resolve relative path values
A record mapping alias names to absolute filesystem paths
// vitest.config.ts
import { defineProject, mergeConfig } from 'vitest/config';
import { getPathAlias } from '@map-colonies/vitest-utils';
import tsconfigJson from './tsconfig.json';
export default mergeConfig(
sharedConfig,
defineProject({
resolve: {
alias: getPathAlias(tsconfigJson, __dirname),
},
})
);
Converts a TypeScript
compilerOptions.pathsmap into a Vitest-compatible alias map.Each path alias key (e.g.
@app/*) is stripped of its trailing/*and mapped to the resolved absolute path of the first entry in its value array.