boredgame/vite.config.ts

56 lines
1.4 KiB
TypeScript
Raw Normal View History

import { sentrySvelteKit } from "@sentry/sveltekit";
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({
plugins: [
sentrySvelteKit({
sourceMapsUploadOptions: {
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
cleanArtifacts: true,
}
}),
sveltekit(), rawFonts(['.ttf'])
],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
},
css: {
devSourcemap: true,
preprocessorOptions: {
postcss: {
additionalData: `
@custom-media --below_small (width < 400px);
@custom-media --below_med (width < 700px);
@custom-media --below_large (width < 900px);
@custom-media --below_xlarge (width < 1200px);
@custom-media --above_small (width > 400px);
@custom-media --above_med (width > 700px);
@custom-media --above_large (width > 900px);
@custom-media --above_xlarge (width > 1200px);
`
}
}
},
resolve: {
alias: {
'.prisma/client/index-browser': './node_modules/@prisma/client/index-browser.js'
}
}
});
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 };
}
}
};
}