-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvite.config.mjs
66 lines (62 loc) · 1.85 KB
/
vite.config.mjs
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
import path from "node:path";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
const rootDirPath = process.cwd();
const outDirPath = path.resolve(rootDirPath, "out", "build");
/**
* @returns {import("vitest").UserConfig}
* @see https://vitejs.dev/config/
*/
export default defineConfig(
({ command, mode }) =>
/** @type {*} */ ({
define: {
__ENV__: JSON.stringify(
command === "build" ? "production" : "development",
),
__USE_LOCAL_API__: JSON.stringify(mode === "mocked"),
__LOCAL_API_PORT__: JSON.stringify(9009),
},
build: {
outDir: outDirPath,
assetsDir: "",
emptyOutDir: true,
minify: command === "build",
},
plugins: [
svelte({
configFile: path.resolve(rootDirPath, "svelte.config.mjs"),
hot: false,
}),
tsconfigPaths({ root: rootDirPath }),
],
test: {
globals: true,
environment: "jsdom",
setupFiles: path.resolve(rootDirPath, "vitest.setup.ts"),
globalSetup: path.resolve(rootDirPath, "vitest.global.mjs"),
cache: {
dir: path.resolve(rootDirPath, "node_modules", ".vitest"),
},
coverage: {
provider: "istanbul",
reporter: ["lcov"],
reportsDirectory: path.resolve(rootDirPath, "out", "coverage"),
include: ["src/**"],
exclude: [
"**/__fakes__/**",
"**/__mocks__/**",
"**/__tests__/**",
"**/__e2e__/**",
"**/*.json",
"**/*.js",
],
// Include _all_ files in coverage, even untested ones:
all: true,
// Clean coverage results before running tests:
clean: true,
},
},
}),
);