forked from cloudflare/vinext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
137 lines (130 loc) · 4.54 KB
/
vite.config.ts
File metadata and controls
137 lines (130 loc) · 4.54 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import { defineConfig } from "vite-plus";
import { randomUUID } from "node:crypto";
export default defineConfig({
staged: {
"*": "vp check --fix",
},
fmt: {
printWidth: 100,
tabWidth: 2,
useTabs: false,
semi: true,
singleQuote: false,
trailingComma: "all",
ignorePatterns: ["tests/fixtures/ecosystem/**", "examples/**"],
},
lint: {
ignorePatterns: [
"fixtures/ecosystem/**",
"tests/fixtures/**",
"tests/fixtures/ecosystem/**",
"examples/**",
],
options: {
typeAware: true,
typeCheck: true,
denyWarnings: true,
},
plugins: ["typescript", "unicorn", "import", "react"],
rules: {
"@typescript-eslint/no-explicit-any": "error",
"typescript/consistent-type-definitions": ["error", "type"],
"@typescript-eslint/no-unsafe-function-type": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-redeclare": "error",
"@typescript-eslint/no-implied-eval": "error",
"unicorn/prefer-node-protocol": "error",
"import/first": "error",
"import/no-duplicates": "error",
"no-new-func": "error",
"no-implied-eval": "error",
"arrow-body-style": ["error", "as-needed"],
"react/exhaustive-deps": "error",
"react/no-array-index-key": "error",
"react/rules-of-hooks": "error",
"react/self-closing-comp": "error",
},
overrides: [
{
files: ["**.spec.ts", "**.test.ts"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
},
},
],
},
test: {
// GitHub Actions reporter adds inline failure annotations in PR diffs.
// Agent reporter suppresses passing test noise when running inside AI agents.
reporters: process.env.CI ? ["default", "github-actions"] : ["default", "agent"],
// Shared env for all projects.
env: {
// Mirrors the Vite `define` in index.ts that inlines a build-time UUID.
// Setting it here means tests exercise the same code path as production.
__VINEXT_DRAFT_SECRET: randomUUID(),
},
projects: [
{
test: {
name: "unit",
include: ["tests/**/*.test.ts"],
exclude: [
"tests/fixtures/**/node_modules/**",
// Integration tests: spin up Vite dev servers against shared fixture
// dirs. Must run serially to avoid Vite deps optimizer cache races
// (node_modules/.vite/*) that produce "outdated pre-bundle" 500s.
// When adding a test that calls startFixtureServer() or createServer(),
// move it here.
"tests/app-router.test.ts",
"tests/api-handler.test.ts",
"tests/cjs.test.ts",
"tests/ecosystem.test.ts",
"tests/entry-templates.test.ts",
"tests/features.test.ts",
"tests/image-optimization-parity.test.ts",
"tests/node-modules-css.test.ts",
"tests/pages-i18n-prod.test.ts",
"tests/pages-router-concurrency.test.ts",
"tests/pages-router.test.ts",
"tests/postcss-resolve.test.ts",
"tests/prerender.test.ts",
"tests/static-export.test.ts",
"tests/vite-hmr-websocket.test.ts",
"tests/nextjs-compat/**/*.test.ts",
// Flaky under parallelism due to 1 MiB buffer allocation pressure.
"tests/kv-cache-handler.test.ts",
],
},
},
{
test: {
name: "integration",
include: [
"tests/app-router.test.ts",
"tests/api-handler.test.ts",
"tests/cjs.test.ts",
"tests/ecosystem.test.ts",
"tests/entry-templates.test.ts",
"tests/features.test.ts",
"tests/image-optimization-parity.test.ts",
"tests/kv-cache-handler.test.ts",
"tests/node-modules-css.test.ts",
"tests/pages-i18n-prod.test.ts",
"tests/pages-router-concurrency.test.ts",
"tests/pages-router.test.ts",
"tests/postcss-resolve.test.ts",
"tests/prerender.test.ts",
"tests/static-export.test.ts",
"tests/vite-hmr-websocket.test.ts",
"tests/nextjs-compat/**/*.test.ts",
],
testTimeout: 30000,
// Serial execution prevents Vite deps optimizer cache races when
// multiple test files share the same fixture directory.
fileParallelism: false,
},
},
],
},
});