-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
37 lines (32 loc) · 951 Bytes
/
vite.config.ts
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
/// <reference types="vitest" />
import { sveltekit } from '@sveltejs/kit/vite';
import type { UserConfig, Plugin } from 'vite';
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
const file = fileURLToPath(new URL('package.json', import.meta.url));
const pkg = JSON.parse(readFileSync(file, 'utf8'));
const viteServerConfig: Plugin = {
name: 'log-request-middleware',
configureServer(server) {
server.middlewares.use((req, res, next) => {
res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Methods", "GET");
res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
next();
});
}
};
const config: UserConfig = {
plugins: [
viteServerConfig,
sveltekit(),
],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
},
define: {
VERSION: JSON.stringify(pkg.version),
},
};
export default config;