chat-aww / vite.config.ts
nsarrazin's picture
nsarrazin HF staff
fix: social thumbnail assistants (#732)
bbbed00 unverified
raw
history blame
706 Bytes
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig, type PluginOption } from "vite";
import Icons from "unplugin-icons/vite";
import { promises } from "fs";
// used to load fonts server side for thumbnail generation
function loadTTFAsArrayBuffer(): PluginOption {
return {
name: "load-ttf-as-array-buffer",
async transform(_src, id) {
if (id.endsWith(".ttf")) {
return `export default new Uint8Array([
${new Uint8Array(await promises.readFile(id))}
]).buffer`;
}
},
};
}
export default defineConfig({
plugins: [
sveltekit(),
Icons({
compiler: "svelte",
}),
loadTTFAsArrayBuffer(),
],
optimizeDeps: {
include: ["browser-image-resizer"],
},
});