vite-plugin-alias is a Vite plugin that automatically generates aliases for your project. Version 0.1.1 is the latest stable release, with updates that add support for Vite 4 and fix build issues. It automatically maps directory structures to import aliases, reducing manual configuration. Compared to alternatives like vite-aliases, it has a similar API but is maintained by elonehoo and includes TypeScript types. The release cadence is irregular but includes bug fixes and compatibility updates.
npm install vite-plugin-aliasVerified import paths — ran on the pinned version, not inferred.
Shows how to install and configure vite-plugin-alias in a Vite project using TypeScript.
Remove any manual 'resolve.alias' entries if using this plugin, or customize the plugin options to avoid overlap.
Upgrade to version 0.0.7 or later to add Vite 4 support.
Use the 'prefix' or 'deep' options to control which directories are scanned and how aliases are named.
Run 'npm install --save-dev vite-plugin-alias' or 'pnpm install --save-dev vite-plugin-alias'.
Use 'import Alias from "vite-plugin-alias"' instead of 'import { Alias } from "vite-plugin-alias"'.Use 'import type { ViteAliasesOptions } from "vite-plugin-alias"' or simply rely on inference.