
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
vite-plugin-import
Advanced tools
Modular import plugin for Vite
npm i vite-plugin-import -D
If the library that you are using tell you to use babel-plugin-import to reduce the bundle size, then you can use @rollup/plugin-babel + babel-plugin-import, or just vite-plugin-import.
If you need some other babel features, use @rollup/plugin-babel + babel-plugin-import, not vite-plugin-import.
vite-plugin-import is a little faster then @rollup/plugin-babel + babel-plugin-import.
vite.config.js:
import createImportPlugin from 'vite-plugin-import';
const config = {
plugins: [
createImportPlugin([
{
libraryName: 'antd',
'style': true, // or 'css'
}
]),
],
}
// or
const config = {
plugins: [
createImportPlugin({
onlyBuild: false, // if onlyBuild === true, this plugin takes effect only in vite build mode; onlyBuild's default value is true.
babelImportPluginOptions: [{
libraryName: 'antd',
'style': true, // or 'css'
}]
}),
],
}
app code:
import { Button } from 'antd';
ReactDOM.render(<Button>xxxx</Button>);
↓ ↓ ↓ ↓ ↓ ↓
var _button = require('antd/lib/button');
require('antd/lib/button/style');
ReactDOM.render(<_button>xxxx</_button>);
Need to clarify that you DO NOT really need vite-plugin-import for antd, because antd is tree shakeable, and vite can remove the unused codes when build.
Internally, vite-plugin-import just use babel + babel-plugin-import for transforming codes.
For performance, vite-plugin-import will only transform codes that contain the module names.
See babel-plugin-import for more detail.
FAQs
Component modular import plugin for vite.
The npm package vite-plugin-import receives a total of 303 weekly downloads. As such, vite-plugin-import popularity was classified as not popular.
We found that vite-plugin-import demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.