a fast-by-default way to bundle assets as Uint8Arrays using base64
npm i vite-plugin-uint8array -D
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
add support for ?uint8array
in module paths
{
"compilerOptions": {
"types": ["vite-plugin-uint8array/types"]
}
}
this was inspired by my original pr to vite-plugin-arraybuffer, so thanks for the foundation tachibana-shin!