-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathvite.config.js
More file actions
63 lines (58 loc) · 1.91 KB
/
vite.config.js
File metadata and controls
63 lines (58 loc) · 1.91 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
// Copyright 2021-2024 Adobe, Copyright 2025 The C2PA Contributors
import { sveltekit } from '@sveltejs/kit/vite';
import fs from 'fs';
import path from 'path';
import svelteSvg from './etc/rollup/plugins/svelte-svg';
function getSupportedLocales() {
const dictPath = path.resolve(__dirname, './locales/');
return fs.readdirSync(dictPath).map((file) => path.basename(file, '.json'));
}
/** @type {import('vite').UserConfig} */
const config = {
server: {
fs: {
allow: ['assets', 'locales'],
},
},
build: {
minify: 'terser',
sourcemap: true,
terserOptions: {
// Added since error names were being mangled, resulting in incorrect error handling
keep_classnames: true,
// image-blob-reduce breaks unless this is disabled
compress: { evaluate: false },
},
},
define: {
__SUPPORTED_LOCALES__: JSON.stringify(getSupportedLocales()),
__OVERRIDE_MANIFEST_RECOVERY_BASE_URL__: JSON.stringify(
process.env.OVERRIDE_MANIFEST_RECOVERY_BASE_URL ?? '',
),
__THUMBNAIL_DATA_TYPE__: JSON.stringify(
process.env.THUMBNAIL_DATA_TYPE ?? 'blob',
),
},
experimental: {
// Hack to make sure Svelte(Kit)/Vite doesn't try to automatically prepend the hostname to
// our asset URLs. This breaks snapshot testing on Percy/Browserstack due to them not being
// able to proxy localhost in Safari (see https://docs.percy.io/docs/browsers-specific-handling#localhost-proxy-support-on-safari).
renderBuiltUrl(filename, { hostType }) {
if (hostType === 'js') {
return {
runtime: `${JSON.stringify(`/${filename}`)}`,
};
} else {
return { relative: true };
}
},
},
plugins: [sveltekit(), svelteSvg()],
test: {
include: ['src/**/*.spec.ts'],
environment: 'jsdom',
setupFiles: ['./src/test/setup.ts'],
setupFilesAfterEnv: ['./src/test/setupAfterEnv.ts'],
},
};
export default config;