boredgame/vite.config.ts

23 lines
508 B
TypeScript
Raw Normal View History

import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
2023-09-14 01:43:22 +00:00
import fs from 'fs';
export default defineConfig({
2023-09-14 01:43:22 +00:00
plugins: [sveltekit(), rawFonts(['.ttf'])],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
}
});
2023-09-14 01:43:22 +00:00
function rawFonts(ext) {
return {
name: 'vite-plugin-raw-fonts',
transform(code, id) {
if (ext.some((e) => id.endsWith(e))) {
const buffer = fs.readFileSync(id);
return { code: `export default ${JSON.stringify(buffer)}`, map: null };
}
}
};
}