npm

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

0.2.0 • Public • Published

unplugin-inject

NPM version

🍣 A universal bundler plugin which scans modules for global variables and injects import statements where necessary.

Install

npm i unplugin-inject
Vite
// vite.config.ts
import UnpluginInject from 'unplugin-inject/vite'

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

Example: playground/


Rollup
// rollup.config.js
import UnpluginInject from 'unplugin-inject/rollup'

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


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


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

This module works for both Nuxt 2 and Nuxt Vite


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


esbuild
// esbuild.config.js
import { build } from 'esbuild'
import UnpluginInject from 'unplugin-inject/esbuild'

build({
  plugins: [UnpluginInject()],
})


Usage

Options

For all options please refer to docs.

This plugin accepts all @rollup/plugin-inject options.

Package Sidebar

Install

npm i unplugin-inject

Weekly Downloads

1

Version

0.2.0

License

MIT

Unpacked Size

28.7 kB

Total Files

45

Last publish

Collaborators

  • wzc520pyfm