-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
39 lines (37 loc) · 1.29 KB
/
vite.config.ts
File metadata and controls
39 lines (37 loc) · 1.29 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
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig, type UserConfig } from 'vite';
const repoName = 'codecmerger';
export default defineConfig(({ mode }): UserConfig => {
return {
// For GitHub Pages, base should be the repository name
// For other deployments, you might not need this or need a different value
base: mode === 'production' ? `/${repoName}/` : '/',
plugins: [
sveltekit(),
// Add a plugin to configure headers for SharedArrayBuffer
{
name: 'configure-response-headers',
configureServer: server => {
server.middlewares.use((_req, res, next) => {
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
next();
});
}
}
],
optimizeDeps: {
exclude: ['@ffmpeg/ffmpeg', '@ffmpeg/util'] // Exclude both as they are often used together
},
// If you plan to use the multi-threaded version of ffmpeg.wasm,
// ensuring server headers are set for SharedArrayBuffer is crucial.
// The plugin above handles this for the dev server.
// For production, your hosting environment needs to set these headers.
server: {
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
},
},
};
});