@wroud/vite-plugin-asset-resolver

0.1.3 • Public • Published

@wroud/vite-plugin-asset-resolver

ESM-only package NPM version

@wroud/vite-plugin-asset-resolver is a flexible Vite plugin that resolves asset imports by mapping 'dist' directories to 'src' directories, supporting custom file extensions. It enables custom asset resolution when Vite’s default behavior fails, particularly for complex project structures.

Features

  • Custom Asset Resolution: Resolves asset imports (e.g., images, SVG) from src instead of dist.
  • Multiple Aliases: Supports custom aliases for both src and dist directories.
  • Custom Extensions: Allows configuring which file extensions should be resolved.

Installation

Install via npm:

npm install @wroud/vite-plugin-asset-resolver

Install via yarn:

yarn add @wroud/vite-plugin-asset-resolver

Documentation

For detailed usage and API reference, visit the documentation site.

Example

import { defineConfig } from "vite";
import { assetResolverPlugin } from "@wroud/vite-plugin-asset-resolver";

export default defineConfig({
  plugins: [
    assetResolverPlugin({
      dist: ["dist", "build"],
      src: ["src", "source"],
      extensions: [".svg", ".png", ".jpg"],
    }),
  ],
});

Changelog

All notable changes to this project will be documented in the CHANGELOG file.

License

This project is licensed under the MIT License. See the LICENSE file for details.

/@wroud/vite-plugin-asset-resolver/

    Package Sidebar

    Install

    npm i @wroud/vite-plugin-asset-resolver

    Homepage

    wroud.dev

    Weekly Downloads

    3

    Version

    0.1.3

    License

    MIT

    Unpacked Size

    12.6 kB

    Total Files

    10

    Last publish

    Collaborators

    • wroud