
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
vite-plugin-alias2
Advanced tools
During the development process, there are a small number of special cases where the path substitution of Vite's native alis is not enough to meet the development needs.So this is again an enhanced version of the foundation, and the plugin is compatible wi
During the development process, there are a small number of special cases where the path substitution of Vite's native alis is not enough to meet the development needs.So this is again an enhanced version of the foundation, and the plugin is compatible with Vite's native alias
npm i vite-plugin-alias2
The plugin supports vue ts tsx js css scss less json ... files The plugin accepts two parameter formats
export interface Alias {
find: string | RegExp;
replacement: string;
}
export interface ViteAliasOptions {
entries?: { [find: string]: string } | Alias[];
}
vite.config.ts
import Alias from 'vite-plugin-alias'
// Array form
plugins: [Alias({
entries: [
{ find: '~', replacement: 'src' },
{ find: '~/style.css', replacement: './style.css' },
{ find: "^@vue/(.*?)$", replacement: 'src/$1/src' },
{ find: /^(.*)\.js$/, replacement: '$1.wasm' },
],
})],
// Object shorthand is supported
plugins: [Alias({
entries: {
'~': '.',
'~/style.css': './style.css',
"^@vue/(.*?)$": 'src/$1/src',
}
})],
<template>
<div></div>
</template>
<script setup lang="ts">
import "@vue/shared";
import "~/da";
import "index.js";
import * as m from "index.js";
import { a } from "./index";
</script>
<style lang="scss" scoped>
@import "~/style.css";
</style>
After compilation, the code wrapped in conditional comments will replace the path
<template>
<div></div>
</template>
<script setup lang="ts">
import "src/shared/src";
import "./da";
import "index.wasm";
import * as m from "index.wasm";
import { a } from "./index";
</script>
<style lang="scss" scoped>
@import "./style.css";
</style>
"
FAQs
During the development process, there are a small number of special cases where the path substitution of Vite's native alis is not enough to meet the development needs.So this is again an enhanced version of the foundation, and the plugin is compatible wi
The npm package vite-plugin-alias2 receives a total of 0 weekly downloads. As such, vite-plugin-alias2 popularity was classified as not popular.
We found that vite-plugin-alias2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.