From 38a1e787c64a069592b1ae14b601d1779c1a64d4 Mon Sep 17 00:00:00 2001 From: matthieu42morin Date: Sun, 28 Apr 2024 13:59:27 +0200 Subject: [PATCH] vite config --- vite.config.ts | 51 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index cbb8b1d..da20e45 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -13,20 +13,66 @@ import tailwindConfig from './tailwind.config' // @ts-expect-error ts(7016) import LightningCSS from 'postcss-lightningcss' +//mine +import { sentrySvelteKit } from '@sentry/sveltekit' +import { purgeCss } from 'vite-plugin-tailwind-purgecss' +import { defineConfig } from 'vitest/config' +import { threeMinifier } from '@yushijinhun/three-minifier-rollup' +import path from 'path' + export default defineConfig({ - envPrefix: 'URARA_', + server: { + host: 'localhost', + port: 5173 + }, + + envPrefix: 'PUBLIC_', build: { sourcemap: false, rollupOptions: { cache: false - } + }, + // to resolve https://github.com/vitejs/vite/issues/6985 + target: 'esnext' + }, + test: { + include: ['src/**/*.{test,spec}.{js,ts}'] + }, + define: { + 'process.env.VITE_BUILD_TIME': JSON.stringify(new Date().toISOString()) }, css: { postcss: { plugins: [TailwindCSS(tailwindConfig), LightningCSS()] } }, + ssr: { + noExternal: ['three'] + }, + resolve: { + alias: { + $lib: path.resolve(__dirname, 'src', 'lib'), + $root: path.resolve(__dirname), + $src: path.resolve(__dirname, 'src'), + $routes: path.resolve(__dirname, 'src', 'routes') + } + }, plugins: [ + sentrySvelteKit({ + sourceMapsUploadOptions: { + org: process.env.SENTRY_ORG, + project: process.env.SENTRY_PROJECT + }, + telemetry: false + }), + SvelteKit(), + purgeCss({ + safelist: { + // any selectors that begin with "hljs-" will not be purged + greedy: [/^hljs-/] + } + }), + { ...threeMinifier(), enforce: 'pre' }, UnoCSS({ content: { pipeline: { include: [/\.svelte$/, /\.md?$/, /\.ts$/] } }, extractors: [extractorSvelte], @@ -38,7 +84,6 @@ export default defineConfig({ ] }), imagetools(), - SvelteKit(), SvelteKitPWA({ registerType: 'autoUpdate', manifest: false,