vite-base64-importer
v0.0.2
Published
Import base64 data from a file in Vite
Downloads
192
Readme
vite-base64-importer
A simple utility to import files as base64 strings in Vite.
How to setup
Add the plugin to your vite.config.ts
file.
// vite.config.ts
import { defineConfig } from "vite";
import { base64Importer } from "vite-base64-importer"; // <- Import the plugin
export default defineConfig({
plugins: [
base64Importer(), // <- Add this line
],
});
How to use
Simply import the file with the ?base64
query parameter.
// some-file.ts
import image from "./image.png?base64";
// ^? string (base64)