unplugin-alias
v0.1.0
Published
[![NPM version](https://img.shields.io/npm/v/unplugin-alias?color=a1b858&label=)](https://www.npmjs.com/package/unplugin-alias)
Downloads
1
Maintainers
Readme
unplugin-alias
This unplugin helps you to setup alias for your bundler automatically by loading your tsconfig.json
with its compilerOptions.paths
field.
And if you use some other runtime, such as JITI, you can use the function mapPathToAlias
to setup manually.
Install
pnpm i unplugin-alias
Usage
export interface Options {
configFile?: string
cwd?: string
}
// vite.config.ts
import Alias from "unplugin-alias/vite"
export default defineConfig({
plugins: [
Alias({
/* options */
}),
],
})
// rollup.config.js
import Alias from "unplugin-alias/rollup"
export default {
plugins: [
Alias({
/* options */
}),
],
}
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require("unplugin-alias/webpack")({
/* options */
}),
],
}
// rspack.config.js
module.exports = {
/* ... */
plugins: [
require("unplugin-alias/rspack")({
/* options */
}),
],
}
// nuxt.config.js
export default defineNuxtConfig({
modules: [
[
"unplugin-alias/nuxt",
{
/* options */
},
],
],
})
This module works for both Nuxt 2 and Nuxt Vite
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require("unplugin-alias/webpack")({
/* options */
}),
],
},
}
Esbuild supports alias out-of-box, so you don't need this plugin.