mirror of
https://github.com/bartvdbraak/hellob.art.git
synced 2025-04-26 17:11:21 +00:00
feat: add type definitions for vite plugin
This commit is contained in:
parent
aa8fb480d0
commit
ea491c3148
3 changed files with 11 additions and 3 deletions
|
@ -4,7 +4,7 @@ import { html as toReactNode } from 'satori-html';
|
|||
import { OgImage } from '$lib/components/site';
|
||||
import GeistRegular from '$lib/assets/og/Geist-Regular.woff';
|
||||
import GeistBold from '$lib/assets/og/Geist-Bold.woff';
|
||||
import imageData from '$lib/assets/og/me-inline.jpg';
|
||||
import imageData from '$lib/assets/og/me-inline.jpg?base64';
|
||||
|
||||
const height = 630;
|
||||
const width = 1200;
|
||||
|
|
7
src/routes/og.png/env.d.ts
vendored
Normal file
7
src/routes/og.png/env.d.ts
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/// <reference types="vite/client" />
|
||||
/// <reference types="vite/types/importMeta" />
|
||||
|
||||
declare module '*?base64' {
|
||||
const src: string;
|
||||
export default src;
|
||||
}
|
|
@ -26,8 +26,9 @@ function base64(ext: string[]) {
|
|||
return {
|
||||
name: 'vite-plugin-base64-loader',
|
||||
transform(_code: string, id: string) {
|
||||
if (id.includes('inline') && ext.some((e) => id.endsWith(e))) {
|
||||
const base64 = fs.readFileSync(id, { encoding: 'base64' });
|
||||
const [path, query] = id.split('?');
|
||||
if (query === 'base64' && ext.some((e) => id.endsWith(e))) {
|
||||
const base64 = fs.readFileSync(path, { encoding: 'base64' });
|
||||
return { code: `export default ${JSON.stringify(base64)}`, map: null };
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue