UNPKG

@winter-love/vite-plugin-monorepo-alias

Version:

vite monorepo alias plugin

36 lines (29 loc) 1.03 kB
# Vite Plugin Monorepo alias A Vite plugin that helps Vite or Vite-based applications correctly resolve alias import paths in a monorepo environment. This plugin provides the following features: - Support for alias imports between packages within a monorepo workspace - Relative path resolution based on source directory - Compatible with TypeScript paths configuration - Consistent path resolution during development and build ## Setting ```ts import {defineConfig} from 'vite' import {monorepoAlias} from '@winter-love/vite-plugin-monorepo-alias' export default defineConfig({ plugins: [ monorepoAlias({ /** * Specify the project root path. */ root: fileURLToPath(new URL('./', import.meta.url)), sourceRoot: 'src', /** * Specify package paths within the monorepo workspace. * apps - All packages in the apps directory * packages - All packages in the packages directory */ workspacePaths: [/^\/apps\//u, /^\/packages\//u], }) ] }) ```