-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathvite.config.js
More file actions
88 lines (76 loc) · 2.31 KB
/
Copy pathvite.config.js
File metadata and controls
88 lines (76 loc) · 2.31 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
import path from "node:path";
import url from "node:url";
import { sveltekit } from "@sveltejs/kit/vite";
import { defineConfig, configDefaults } from "vitest/config";
import { svelteTesting } from "@testing-library/svelte/vite";
const __filename = url.fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const localServer = {
host: "0.0.0.0",
port: process.env.DOCKER ? 80 : 5173,
origin: "https://www.dev.documentcloud.org",
};
const remoteServer = {
host: "0.0.0.0",
port: 5173,
origin: "https://local.staging.documentcloud.org:5173",
https: {
key: path.resolve(
__dirname,
"certs/local.staging.documentcloud.org-key.pem",
),
cert: path.resolve(__dirname, "certs/local.staging.documentcloud.org.pem"),
},
};
export default defineConfig(({ mode }) => ({
build: {
sourcemap: true,
target: "esnext",
},
define: {
"process.env.NODE_ENV": JSON.stringify(mode),
"process.env.DEPLOY_PRIME_URL": JSON.stringify(
process.env.DEPLOY_PRIME_URL,
),
"process.env.APP_URL": JSON.stringify(process.env.APP_URL),
},
plugins: [sveltekit(), svelteTesting()],
// allow top-level await
optimizeDeps: {
esbuildOptions: {
target: "esnext",
},
},
resolve: {
// Add 'browser' condition in test mode so Svelte lifecycle hooks
// (onMount, etc.) work correctly instead of being SSR no-ops.
// See: https://github.com/testing-library/svelte-testing-library/issues/222
...(process.env.VITEST ? { conditions: ["browser"] } : {}),
alias: {
"@": path.resolve(__dirname, "src"),
},
},
server: process.env.NODE_ENV === "remote" ? remoteServer : localServer,
ssr: {
noExternal: ["intl-messageformat"],
},
test: {
setupFiles: ["./vitest-setup.js"],
include: ["src/**/*.{test,spec}.{js,ts}", "src/**/*.{test,spec}.svelte.ts"],
exclude: [
...configDefaults.exclude,
"storybook-static",
"./src/legacy/modification",
"node_modules",
"./src/config/*",
"./src/**/*.stories.@(js|jsx|ts|tsx|svelte)",
],
environment: "jsdom",
coverage: {
provider: "v8",
include: ["src/lib/**", "src/routes/**"],
exclude: ["src/**/*.stories.@(js|jsx|ts|tsx|svelte)"],
reporter: ["text", "html", "lcov", "clover", "json", "json-summary"],
},
},
}));