https://github.com/mingtianyihou33/vite-plugin-replace-lodash
Replacing the import of lodash with lodash-es is more beneficial to tree-shaking
https://github.com/mingtianyihou33/vite-plugin-replace-lodash
Last synced: 8 days ago
JSON representation
Replacing the import of lodash with lodash-es is more beneficial to tree-shaking
- Host: GitHub
- URL: https://github.com/mingtianyihou33/vite-plugin-replace-lodash
- Owner: mingtianyihou33
- License: mit
- Created: 2024-11-20T02:31:25.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2025-02-13T07:07:43.000Z (2 months ago)
- Last Synced: 2025-03-21T20:45:40.654Z (29 days ago)
- Language: TypeScript
- Homepage:
- Size: 56.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- fucking-awesome-vite - vite-plugin-replace-lodash - Replacing the import of `lodash` with `lodash-es` is more beneficial to tree-shaking. (Plugins / Framework-agnostic Plugins)
- awesome-vite - vite-plugin-replace-lodash - Replacing the import of `lodash` with `lodash-es` is more beneficial to tree-shaking. (Plugins / Framework-agnostic Plugins)
README
# vite-plugin-replace-lodash
**English** | [中文](./README.zh_CN.md)
A `Vite` plugin is used to replace `lodash` with `lodash-es` to prevent all lodash modules are imported and the bundle volume is too large because it cannot tree-shaking.
Notice: The `lodash-es` module needs to be installed separately.
## Install
npm:
```bash
npm install vite-plugin-replace-lodash -D
```pnpm:
```bash
pnpm add vite-plugin-replace-lodash -D
```## Usage
```typescript
import { defineConfig } from 'vite';
import { replaceLodash } from 'vite-plugin-replace-lodash';export default defineConfig({
plugins: [replaceLodash()],
})
```