New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

vite-plugin-virtual-alias

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

vite-plugin-virtual-alias

[![npm version](https://img.shields.io/npm/v/vite-plugin-virtual-alias.svg?style=flat-square)](https://www.npmjs.com/package/vite-plugin-virtual-alias) [![License: MIT](https://img.shields.io/badge/License-MIT-cyan.svg?style=flat-square)](https://github.c

latest
Source
npmnpm
Version
2.1.5
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Vite Plugin Virtual Alias

npm version License: MIT npm downloads

English | 中文

A lightweight Vite plugin that provides powerful virtual alias functionality, allowing you to map custom virtual paths to actual files in your project during the build process.

📦 Installation

Install with your favorite package manager:

# Using npm
npm install -D vite-plugin-virtual-alias

# Using yarn
yarn add -D vite-plugin-virtual-alias

# Using pnpm
pnpm add -D vite-plugin-virtual-alias

🚀 Basic Usage

Configuration

Add the plugin to your Vite configuration:

// vite.config.ts
import { defineConfig } from 'vite'
import { virtualAlias } from 'vite-plugin-virtual-alias'

export default defineConfig({
  plugins: [
    virtualAlias({
      mappings: [
        {
          // Virtual path
          proto: 'virtual:config.ts',
          // Mapped path
          resolve: 'path/to/your/custom/config.alias.ts',
          // or
          // source: 'path/to/your/custom/config.alias.ts',
        },
      ],
    }),
  ],
})

Example Usage

After configuration, you can use the virtual alias in your code:

// Import using virtual alias
import config from 'virtual:config.ts'

console.log(config) // Will be resolved to path/to/your/custom/config.alias.ts

🔍 How It Works

  • resolve: Uses Vite's resolveId hook for path mapping, which affects the built file names
  • source: Uses the load hook to directly return file content, keeping the original file names

🤝 Contributing

Contributions are welcome! Please feel free to submit issues and pull requests. For major changes, please open an issue first to discuss what you would like to change.

📄 License

MIT © AhMisty

Keywords

vite-plugin-virtual-alias

FAQs

Package last updated on 06 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts