unplugin-alias
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

unplugin-alias

NPM version

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
// vite.config.ts
import Alias from "unplugin-alias/vite"

export default defineConfig({
  plugins: [
    Alias({
      /* options */
    }),
  ],
})


Rollup
// rollup.config.js
import Alias from "unplugin-alias/rollup"

export default {
  plugins: [
    Alias({
      /* options */
    }),
  ],
}


Webpack
// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require("unplugin-alias/webpack")({
      /* options */
    }),
  ],
}


Rspack
// rspack.config.js
module.exports = {
  /* ... */
  plugins: [
    require("unplugin-alias/rspack")({
      /* options */
    }),
  ],
}


Nuxt
// nuxt.config.js
export default defineNuxtConfig({
  modules: [
    [
      "unplugin-alias/nuxt",
      {
        /* options */
      },
    ],
  ],
})

This module works for both Nuxt 2 and Nuxt Vite


Vue CLI
// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [
      require("unplugin-alias/webpack")({
        /* options */
      }),
    ],
  },
}


esbuild

Esbuild supports alias out-of-box, so you don't need this plugin.


Package Sidebar

Install

npm i unplugin-alias

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

24.1 kB

Total Files

37

Last publish

Collaborators

  • ayingott