unplugin-dynamic-import-vars
v0.2.0
Published
A universal bundler plugin to support variables in dynamic imports in Bundler.
Downloads
7
Maintainers
Readme
unplugin-dynamic-import-vars
🍣 A universal bundler plugin to support variables in dynamic imports in Bundler.
Install
npm i unplugin-dynamic-import-vars
// vite.config.ts
import UnpluginDynamicImportVars from 'unplugin-dynamic-import-vars/vite'
export default defineConfig({
plugins: [
UnpluginDynamicImportVars({
/* options */
}),
],
})
Example: playground/
// rollup.config.js
import UnpluginDynamicImportVars from 'unplugin-dynamic-import-vars/rollup'
export default {
plugins: [
UnpluginDynamicImportVars({
/* options */
}),
],
}
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('unplugin-dynamic-import-vars/webpack')({
/* options */
}),
],
}
// nuxt.config.js
export default defineNuxtConfig({
modules: [
[
'unplugin-dynamic-import-vars/nuxt',
{
/* options */
},
],
],
})
This module works for both Nuxt 2 and Nuxt Vite
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('unplugin-dynamic-import-vars/webpack')({
/* options */
}),
],
},
}
// esbuild.config.js
import { build } from 'esbuild'
import UnpluginDynamicImportVars from 'unplugin-dynamic-import-vars/esbuild'
build({
plugins: [UnpluginDynamicImportVars()],
})
Usage
Options
For all options please refer to docs.
This plugin accepts all @rollup/plugin-dynamic-import-vars options.