unplugin-inject
v0.2.0
Published
A universal bundler plugin which scans modules for global variables and injects `import` statements where necessary.
Downloads
5
Maintainers
Readme
unplugin-inject
🍣 A universal bundler plugin which scans modules for global variables and injects import
statements where necessary.
Install
npm i unplugin-inject
// vite.config.ts
import UnpluginInject from 'unplugin-inject/vite'
export default defineConfig({
plugins: [
UnpluginInject({
/* options */
}),
],
})
Example: playground/
// rollup.config.js
import UnpluginInject from 'unplugin-inject/rollup'
export default {
plugins: [
UnpluginInject({
/* options */
}),
],
}
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-inject/webpack')({
/* options */
}),
],
}
// nuxt.config.js
export default defineNuxtConfig({
modules: [
[
'unplugin-inject/nuxt',
{
/* options */
},
],
],
})
This module works for both Nuxt 2 and Nuxt Vite
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-inject/webpack')({
/* options */
}),
],
},
}
// 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.