/
vite.config.ts
73 lines (67 loc) · 1.96 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
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
/// <reference types="vitest" />
import vue from "@vitejs/plugin-vue";
import fs from "fs";
import { fileURLToPath, URL } from "url";
import { defineConfig, loadEnv, searchForWorkspaceRoot } from "vite";
import { separateTailwind } from "./config/vite-plugin-separate-tailwind";
const resolve = (path: string) => fileURLToPath(new URL(path, import.meta.url));
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const cwd = process.cwd();
const env = loadEnv(mode, cwd, "BUILDTIME_");
const wasmSupported = (env.BUILDTIME_WASM_SUPPORTED ?? "true") === "true";
const sunriseRoot = wasmSupported
? env.BUILDTIME_SUNRISE_CLI_ROOT ?? "../sunrise-cli"
: "./src/fake/sunrise-cli";
return {
server: {
fs: {
allow: [searchForWorkspaceRoot(cwd), sunriseRoot],
},
host: env.BUILDTIME_HOST,
},
build: {
sourcemap: true,
rollupOptions: {
// TODO: remove this once @types/node gets updated to support node 18
external: ["node:test"],
},
},
test: {
environment: "happy-dom",
includeSource: ["./src/**/*.ts"],
exclude: ["**/*.node-test.*"],
isolate: false, // major speed improvement at risk of cross-contamination
snapshotFormat: {
printBasicPrototype: true,
},
coverage: {
reporter: ["html-spa", "text"],
reportsDirectory: "public/coverage",
},
},
define: {
__VUE_OPTIONS_API__: false,
"import.meta.vitest": "undefined",
__PLAYGROUND_VUE_COVERAGE_EXISTS__: fs.existsSync(
resolve("./public/coverage/index.html")
),
},
resolve: {
alias: {
"@sunrise-cli": resolve(sunriseRoot),
"@": resolve("./src"),
},
},
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement: (tag) => tag.includes("-"),
},
},
}),
mode === "production" && separateTailwind(),
],
};
});