2022-09-29 22:21:48 +00:00
|
|
|
import { sveltekit } from '@sveltejs/kit/vite';
|
2023-05-15 04:08:30 +00:00
|
|
|
import { defineConfig } from 'vite';
|
2023-09-14 01:43:22 +00:00
|
|
|
import fs from 'fs';
|
2022-09-29 22:21:48 +00:00
|
|
|
|
2023-05-15 04:08:30 +00:00
|
|
|
export default defineConfig({
|
2023-09-14 01:43:22 +00:00
|
|
|
plugins: [sveltekit(), rawFonts(['.ttf'])],
|
2023-06-30 22:08:45 +00:00
|
|
|
test: {
|
|
|
|
|
include: ['src/**/*.{test,spec}.{js,ts}']
|
|
|
|
|
}
|
2023-05-15 04:08:30 +00:00
|
|
|
});
|
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 };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|