UNPKG

@wroud/vite-plugin-asset-resolver

Version:

A Vite plugin for custom asset resolution, mapping 'dist' to 'src' directories and resolving files like SVG, images, and other resources. Supports multiple directory aliases and file extensions for flexible module resolution.

22 lines 711 B
import path from "path"; export function* getPossiblePaths(importer, dist, src) { const pathParts = importer.split(path.posix.sep); let distIndex = -1; for (let i = pathParts.length - 1; i >= 0; i--) { if (dist.includes(pathParts[i])) { distIndex = i; break; } } if (distIndex !== -1) { for (const srcAlias of src) { pathParts[distIndex] = srcAlias; let adjustedImporter = path.posix.join(...pathParts); if (importer.startsWith("/")) { adjustedImporter = "/" + adjustedImporter; } yield adjustedImporter; } } } //# sourceMappingURL=getPossiblePaths.js.map