A vite plugin to support variables in dynamic imports module in Vite
pnpm add vite-plugin-dynamic-import-module -D
import { defineConfig } from 'vite'
import importDynamicModule from 'vite-plugin-dynamic-import-module'
export default defineConfig({
plugins: [importDynamicModule()],
})
Type: string
| Array<string>
Default: []
Files to include in this plugin (default all).
Type: string
| Array<string>
Default: []
Files to exclude in this plugin (default none).
Type: Array<string>
Default: ['js', 'cjs', 'ts', 'tsx', 'jsx', 'mjs', 'mts', 'mtsx']
Automatically add default extensions when your import path has no extensions
// Allowed
import(`@ant-design/icons/${name}`)
import(`@ant-design/icons/${name}.js`)
import(`@ant-design/icons/${name}Outlined`)
import(`@ant-design/icons/${name}Outlined.js`)
// Not allowed
// cannot find module
import(`@ant-design/${module}/${name}`)
// module as @ant-design
import(`@ant-design/${module}${name}`)
// module as @ant-design/icons/es/icons
import(`@ant-design/icons/es/icons/${name}`)