vite config

This commit is contained in:
matthieu42morin 2024-04-28 13:59:27 +02:00
parent 2a567b6c9a
commit 38a1e787c6
1 changed files with 48 additions and 3 deletions

View File

@ -13,20 +13,66 @@ import tailwindConfig from './tailwind.config'
// @ts-expect-error ts(7016) // @ts-expect-error ts(7016)
import LightningCSS from 'postcss-lightningcss' 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({ export default defineConfig({
envPrefix: 'URARA_', server: {
host: 'localhost',
port: 5173
},
envPrefix: 'PUBLIC_',
build: { build: {
sourcemap: false, sourcemap: false,
rollupOptions: { rollupOptions: {
cache: false 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: { css: {
postcss: { postcss: {
plugins: [TailwindCSS(tailwindConfig), LightningCSS()] 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: [ 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({ UnoCSS({
content: { pipeline: { include: [/\.svelte$/, /\.md?$/, /\.ts$/] } }, content: { pipeline: { include: [/\.svelte$/, /\.md?$/, /\.ts$/] } },
extractors: [extractorSvelte], extractors: [extractorSvelte],
@ -38,7 +84,6 @@ export default defineConfig({
] ]
}), }),
imagetools(), imagetools(),
SvelteKit(),
SvelteKitPWA({ SvelteKitPWA({
registerType: 'autoUpdate', registerType: 'autoUpdate',
manifest: false, manifest: false,