An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

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()],
})
```