https://github.com/kevlened/vite-plugin-uint8array
https://github.com/kevlened/vite-plugin-uint8array
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kevlened/vite-plugin-uint8array
- Owner: kevlened
- License: mit
- Created: 2024-02-29T13:53:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-29T19:04:45.000Z (over 1 year ago)
- Last Synced: 2025-02-22T06:17:37.105Z (8 months ago)
- Language: TypeScript
- Size: 63.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
a fast-by-default way to bundle assets as Uint8Arrays using base64
## install
```sh
npm i vite-plugin-uint8array -D
```## usage
in `vite.config.ts`
```js
import { defineConfig } from 'vite'
import uint8array from 'vite-plugin-uint8array'export default defineConfig({
plugins: [uint8array()]
})
```in your files
```js
import example from './example.png?uint8array'// example is a Uint8Array
// example.buffer is an ArrayBuffer
```## typescript
add support for `?uint8array` in module paths
```js
{
"compilerOptions": {
"types": ["vite-plugin-uint8array/types"]
}
}
```## hat tip
this was inspired by [my original pr to vite-plugin-arraybuffer](https://github.com/tachibana-shin/vite-plugin-arraybuffer/pull/6), so thanks for the foundation [tachibana-shin](https://github.com/tachibana-shin)!