# vite-plugin-sprite

> vite sprite plugin

Latest version **1.0.2** (published 2024-04-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install vite-plugin-sprite
pnpm add vite-plugin-sprite
yarn add vite-plugin-sprite
bun add vite-plugin-sprite
```

Provides the command `vite-plugin-sprite`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2024-04-22 |
| First published | 2024-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 (+13 in 2 direct dependencies) |
| Install scripts | no |
| Author | Russell |
| Maintainers | wq1308786830 |
| Keywords | sprite, sprites, vite, 雪碧图, 多图合并 |

## Links

- npm: https://www.npmjs.com/package/vite-plugin-sprite
- Homepage: https://github.com/wq1308786830/vite-plugin-sprite
- npm.io page: https://npm.io/package/vite-plugin-sprite

## Dependencies (3)

- [glob](https://npm.io/package/glob.md) ^10.3.12
- [vite](https://npm.io/package/vite.md) ^4.5.3
- [spritesmith](https://npm.io/package/spritesmith.md) ^3.4.1

## 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

- 1.0.2 (latest) — 2024-04-22
- 1.0.1 — 2024-04-22
- 1.0.0 — 2024-04-22

## README

# vite-plugin-sprite
vite-plugin-sprite 是一个基于nodejs生成雪碧图的vite插件，可以将指定任意文件夹下的图文件合并为一张图，并输出最终图文件以及css定位文件方便使用。

支持的格式：`['.png', '.jpg', '.jpeg', '.gif']`

需要注意的是，gif虽然支持，但是由于合并图片只能是静态图，所以只会取gif第一帧作为合并源。

使用：
```
npm i vite-plugin-sprite -D
```
```js
import vitePluginSprite from 'vite-plugin-sprite'

export default defineConfig(({ command, mode }) => {
  return {
    // ...
    plugins: [
      // ...
      vitePluginSprite({ source: '**/sprite' })
    ]
  }
})
```

入参:
```js
source // 支持指定任意目录包括递归目录，如： sprite, ./sprite, **/sprite， test/**/sprite等合法路径。
scale // css像素数值的缩放倍数，方便在css中使用。
```

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