🍣 A universal bundler plugin for defining aliases when bundling packages.
npm i unplugin-alias2
Vite
// vite.config.ts
import UnpluginAlias from 'unplugin-alias2/vite'
export default defineConfig({
plugins: [
UnpluginAlias({
/* options */
}),
],
})
Example: playground/
Rollup
// rollup.config.js
import UnpluginAlias from 'unplugin-alias2/rollup'
export default {
plugins: [
UnpluginAlias({
/* options */
}),
],
}
Webpack
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-alias2/webpack')({
/* options */
}),
],
}
Nuxt
// nuxt.config.js
export default defineNuxtConfig({
modules: [
[
'unplugin-alias2/nuxt',
{
/* options */
},
],
],
})
This module works for both Nuxt 2 and Nuxt Vite
Vue CLI
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-alias2/webpack')({
/* options */
}),
],
},
}
esbuild
// esbuild.config.js
import { build } from 'esbuild'
import UnpluginAlias from 'unplugin-alias2/esbuild'
build({
plugins: [UnpluginAlias()],
})
For all options please refer to docs.
This plugin accepts all @rollup/plugin-alias options.