feat: added svelte component render for og-images

This commit is contained in:
Bart van der Braak 2024-01-19 01:49:35 +01:00
parent 1be9ad4668
commit 3bb7737625
10 changed files with 239 additions and 236 deletions

View file

@ -1,9 +1,10 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { enhancedImages } from '@sveltejs/enhanced-img';
import { defineConfig } from 'vite';
import fs from 'fs';
export default defineConfig({
plugins: [enhancedImages(), sveltekit()],
plugins: [enhancedImages(), sveltekit(), rawFonts(['.woff'])],
ssr: {
noExternal: ['three']
},
@ -11,3 +12,15 @@ export default defineConfig({
'import.meta.env.VERCEL_ANALYTICS_ID': JSON.stringify(process.env.VERCEL_ANALYTICS_ID)
}
});
function rawFonts(ext: string[]) {
return {
name: 'vite-plugin-raw-fonts',
transform(_code: string, id: string) {
if (ext.some((e) => id.endsWith(e))) {
const buffer = fs.readFileSync(id);
return { code: `export default ${JSON.stringify(buffer)}`, map: null };
}
}
};
}