2024-04-28 11:44:18 +00:00
|
|
|
// vite define config
|
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
// vite plugin
|
|
|
|
import UnoCSS from 'unocss/vite'
|
|
|
|
import { presetTagify, presetIcons } from 'unocss'
|
|
|
|
import extractorSvelte from '@unocss/extractor-svelte'
|
|
|
|
import { imagetools } from 'vite-imagetools'
|
|
|
|
import { sveltekit as SvelteKit } from '@sveltejs/kit/vite'
|
|
|
|
import { SvelteKitPWA } from '@vite-pwa/sveltekit'
|
|
|
|
// postcss & tailwindcss
|
|
|
|
import TailwindCSS from 'tailwindcss'
|
|
|
|
import tailwindConfig from './tailwind.config'
|
|
|
|
// @ts-expect-error ts(7016)
|
|
|
|
import LightningCSS from 'postcss-lightningcss'
|
2023-11-01 23:36:58 +00:00
|
|
|
|
2024-04-28 11:59:27 +00:00
|
|
|
//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'
|
|
|
|
|
2023-11-01 23:36:58 +00:00
|
|
|
export default defineConfig({
|
2024-04-29 02:57:05 +00:00
|
|
|
server: {
|
|
|
|
host: 'localhost',
|
|
|
|
port: 5173
|
|
|
|
},
|
2024-04-28 11:59:27 +00:00
|
|
|
|
2024-04-29 02:57:05 +00:00
|
|
|
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()]
|
|
|
|
}
|
2024-04-28 11:59:27 +00:00
|
|
|
},
|
2024-04-29 02:57:05 +00:00
|
|
|
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: 'mattmor',
|
|
|
|
project: 'itspersonal',
|
|
|
|
authToken: process.env.SENTRY_AUTH_TOKEN
|
|
|
|
},
|
|
|
|
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],
|
|
|
|
presets: [
|
|
|
|
presetTagify({
|
|
|
|
extraProperties: (matched: string) => (matched.startsWith('i-') ? { display: 'inline-block' } : {})
|
|
|
|
}),
|
|
|
|
presetIcons({ scale: 1.5 })
|
|
|
|
]
|
2024-04-28 11:44:18 +00:00
|
|
|
}),
|
2024-04-29 02:57:05 +00:00
|
|
|
imagetools(),
|
|
|
|
SvelteKitPWA({
|
|
|
|
registerType: 'autoUpdate',
|
|
|
|
manifest: false,
|
|
|
|
scope: '/',
|
|
|
|
workbox: {
|
|
|
|
globPatterns: ['posts.json', '**/*.{js,css,html,svg,ico,png,webp,avif}'],
|
|
|
|
globIgnores: ['**/sw*', '**/workbox-*']
|
|
|
|
}
|
|
|
|
})
|
|
|
|
]
|
2024-04-28 11:44:18 +00:00
|
|
|
})
|