-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
40 lines (37 loc) · 1.04 KB
/
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
38
39
40
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig } from "vitest/config";
import mkcert from 'vite-plugin-mkcert'
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
const file = fileURLToPath(new URL('package.json', import.meta.url)),
json = readFileSync(file, 'utf8'),
pkg = JSON.parse(json);
/** @type {import('vite').Plugin} */
const viteServerConfig = {
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", "unsafe-none");
res.setHeader("Cross-Origin-Embedder-Policy", "unsafe-none");
next();
});
}
};
export default defineConfig({
plugins: [
sveltekit(),
mkcert(),
viteServerConfig
],
test: {
include: ["src/**/*.{test,spec}.{js,ts}"],
},
define: {
version: {
value: pkg.version,
}
},
debug: true
});