Documentation
    Preparing search index...
    • Converts a TypeScript compilerOptions.paths map 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.

      Parameters

      • tsconfig: { compilerOptions: { paths: Record<string, string[]> } }

        A partial tsconfig object containing compilerOptions.paths

      • rootDir: string

        The root directory used to resolve relative path values

      Returns Record<string, string>

      A record mapping alias names to absolute filesystem paths

      Error If an alias entry has an empty path array

      // 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),
      },
      })
      );