-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
94 lines (90 loc) · 3.19 KB
/
Copy pathvite.config.ts
File metadata and controls
94 lines (90 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { sentrySvelteKit } from '@sentry/sveltekit/vite';
import adapter from '@sveltejs/adapter-static';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import { isAbsolute, relative, resolve } from 'node:path';
import { fetchDeepFilterNet } from './scripts/fetch-deepfilternet.mjs';
const wasmOutput = process.env.SABLE_WASM_OUTPUT ?? 'src/generated/wasm';
export default defineConfig({
optimizeDeps: {
exclude: ['phosphor-svelte'],
},
resolve: {
alias: {
'#src/generated/wasm': resolve(wasmOutput),
},
},
worker: {
rolldownOptions: {
output: {
entryFileNames: '_app/immutable/workers/[name]-[hash].js',
chunkFileNames: '_app/immutable/workers/chunks/[hash].js',
assetFileNames: '_app/immutable/workers/assets/[name]-[hash][extname]',
hoistTransitiveImports: false,
},
},
},
server: {
// Keep the frontend endpoint aligned with src-tauri/tauri.conf.json.
port: 3000,
strictPort: true,
watch: {
ignored: (path) => {
const file = isAbsolute(path) ? relative(process.cwd(), path) : path;
if (!file) return false;
// A build rewrites these, and the reload it triggers cannot help anyway:
// the SharedWorker holding the old wasm outlives it.
if (file === 'src/generated/wasm' || file.startsWith('src/generated/wasm/')) return true;
return file !== 'src' && !file.startsWith('src/') && file !== 'vite.config.ts';
},
},
},
plugins: [
{
name: 'deepfilternet-assets',
buildStart: async () => {
if (!process.env.VITEST) await fetchDeepFilterNet();
},
},
sentrySvelteKit({
// The plugin detects the adapter from `svelte.config.js`, which this
// project does not have, and does not know `adapter-static` either.
adapter: 'other',
autoUploadSourceMaps: Boolean(process.env.SENTRY_AUTH_TOKEN),
authToken: process.env.SENTRY_AUTH_TOKEN,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
release: { name: process.env.VITE_APP_VERSION },
sourcemaps: {
// Upload discovery uses SvelteKit's output; neither copy may ship maps.
filesToDeleteAfterUpload: ['./.svelte-kit/output/**/*.map', './dist/**/*.map'],
},
}),
sveltekit({
compilerOptions: {
// Force runes mode for the project, except for libraries. Can be removed in svelte 6.
runes: ({ filename }) =>
filename.split(/[/\\]/).includes('node_modules') ? undefined : true,
},
// The web build is a client-side app served as Cloudflare Worker assets.
// Dynamic app routes are resolved by the client after Cloudflare's SPA
// fallback serves the root document
paths: {
// Cloudflare's SPA fallback may serve this document from a nested route.
// Absolute asset URLs prevent the browser requesting `/<route>/_app/...`.
relative: false,
},
prerender: {
handleUnseenRoutes: 'ignore',
},
serviceWorker: {
register: false,
},
adapter: adapter({
assets: 'dist',
pages: 'dist',
fallback: '404.html',
}),
}),
],
});