vite-plugin-uint8array
v1.0.0
Published
Minimalist Vite plugin to import files as Uint8Arrays
Downloads
108
Readme
a fast-by-default way to bundle assets as Uint8Arrays using base64
install
npm i vite-plugin-uint8array -D
usage
in vite.config.ts
import { defineConfig } from 'vite'
import uint8array from 'vite-plugin-uint8array'
export default defineConfig({
plugins: [uint8array()]
})
in your files
import example from './example.png?uint8array'
// example is a Uint8Array
// example.buffer is an ArrayBuffer
typescript
add support for ?uint8array
in module paths
{
"compilerOptions": {
"types": ["vite-plugin-uint8array/types"]
}
}
hat tip
this was inspired by my original pr to vite-plugin-arraybuffer, so thanks for the foundation tachibana-shin!