A Vite plugin that transforms component library imports from named imports to individual path imports, automatically appending CSS imports. Version 2.0.5 is the current stable release. It mimics babel-plugin-import behavior in the Vite ecosystem, supporting libraries like Vant, Element Plus, and Ant Design Vue. The plugin operates as a Babel plugin during Vite's transform phase, offering configuration for library directory and style path customization. Compared to manual tree-shaking or full imports, it provides automatic granular imports without additional build configuration.
npm install vite-plugin-babel-importVerified import paths — ran on the pinned version, not inferred.
Setup vite-plugin-babel-import in Vite config and demonstrate transformation of a named import to individual path plus CSS import.
Consider using unplugin-vue-components or manual tree-shaking for newer Vite versions.
Test both dev and build outputs to ensure transformations are applied.
Wrap single config in an array: vitePluginImport([{ ... }])Ensure Vite >=3.x; if on Vite 2, use older version.
Log the name parameter to verify casing.
Run `npm install vite-plugin-babel-import --save-dev` and ensure import path matches package name.
Use default import: `import vitePluginImport from 'vite-plugin-babel-import'`
Wrap config in array: `vitePluginImport([{ libraryName: 'vant' }])`Add a new config entry for the library in the plugin options.
No dependency data recorded yet.