# @univerjs/vite-plugin

> Vite plugin for easily integrating Univer

Latest version **0.5.1** (published 2024-11-12) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @univerjs/vite-plugin
pnpm add @univerjs/vite-plugin
yarn add @univerjs/vite-plugin
bun add @univerjs/vite-plugin
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.1 |
| Published | 2024-11-12 |
| First published | 2024-02-21 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | DreamNum |
| Maintainers | yuhongz, wbfsa, jikkai, wendellhu95, mengshukeji |
| Keywords | univer, univerjs, vite, vite plugin |

## Links

- npm: https://www.npmjs.com/package/@univerjs/vite-plugin
- npm.io page: https://npm.io/package/@univerjs/vite-plugin

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.5.1 (latest) — 2024-11-12
- 0.5.0 — 2024-07-15
- 0.4.4 — 2024-06-18
- 0.4.3 — 2024-06-04
- 0.4.2 — 2024-06-04
- 0.4.1 — 2024-06-03
- 0.4.0 — 2024-06-03
- 0.3.5 — 2024-05-16
- 0.3.4 — 2024-05-16
- 0.3.3 — 2024-05-11
- 0.3.2 — 2024-03-21
- 0.3.1 — 2024-03-21
- 0.3.0 — 2024-02-27
- 0.2.6 — 2024-02-23
- 0.2.5 — 2024-02-23
- … 4 more at https://npm.io/package/@univerjs/vite-plugin/versions

## README

# @univerjs/vite-plugin

## Installation

```bash
npm install @univerjs/vite-plugin
```

## Usage

Add the plugin to your `vite.config.ts`:

```typescript
import { univerPlugin } from '@univerjs/vite-plugin'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [
    univerPlugin()
  ]
})
```

## Features

### Automatic Import of Required CSS

This feature is enabled by default. You can disable it by passing `css: false` to the plugin options.

```diff
export default defineConfig({
  plugins: [
    univerPlugin({
+      css: false
    })
  ]
})
```

### Simplified Import of Language Packs

The plugin provides a virtual module `univer:locales`, which simplifies the import of language packs.

```typescript
import { LocaleType } from '@univerjs/core'

import { enUS, faIR, ruRU, viVN, zhCN, zhTW } from 'univer:locales'

new Univer({
  locales: {
    [LocaleType.ZH_CN]: zhCN,
    [LocaleType.EN_US]: enUS,
    [LocaleType.RU_RU]: ruRU,
    [LocaleType.VI_VN]: viVN,
    [LocaleType.ZH_TW]: zhTW,
    [LocaleType.FA_IR]: faIR,
  }
})
```

## TypeScript Support

In order for TypeScript to recognize the `univer:locales` import, you should add a reference to the `src/vite-env.d.ts` file in your project.

```diff
/// <reference types="vite/client" />
+ /// <reference types="@univerjs/vite-plugin/types" />
```

## Options

- `css`: `boolean` - Whether to automatically import required CSS. Default is `true`.

---
_Source: https://npm.io/package/@univerjs/vite-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
