-
-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathvite.config.ts
More file actions
156 lines (145 loc) · 4.56 KB
/
Copy pathvite.config.ts
File metadata and controls
156 lines (145 loc) · 4.56 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import babel from "@rolldown/plugin-babel";
import tailwindcss from "@tailwindcss/vite";
import { devtools } from "@tanstack/devtools-vite";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import viteReact, { reactCompilerPreset } from "@vitejs/plugin-react";
import { nitro } from "nitro/vite";
import { defineConfig, lazyPlugins } from "vite-plus";
import { version } from "./package.json";
// https://viteplus.dev/config/
export default defineConfig(({ mode }) => ({
// Git hooks for staged files - https://viteplus.dev/guide/commit-hooks
staged: {
"*": "vp fmt --no-error-on-unmatched-pattern",
},
// Vitest (via Vite+) - https://viteplus.dev/guide/test
test: {
include: ["src/**/*.test.{ts,tsx}"],
passWithNoTests: true,
},
// Oxfmt - https://oxc.rs/docs/guide/usage/formatter/config.html
fmt: {
tabWidth: 2,
semi: true,
printWidth: 100,
singleQuote: false,
endOfLine: "lf",
trailingComma: "all",
sortImports: {},
sortTailwindcss: {
stylesheet: "./src/styles.css",
attributes: ["class", "className"],
functions: ["clsx", "cn", "cva", "tw"],
},
sortPackageJson: true,
ignorePatterns: [
"pnpm-lock.yaml",
"package-lock.json",
"yarn.lock",
"bun.lock",
"routeTree.gen.ts",
".tanstack-start/",
".tanstack/",
"drizzle/",
"migrations/",
".drizzle/",
".cache",
"worker-configuration.d.ts",
".vercel",
".output",
".wrangler",
".netlify",
"dist",
],
},
// Oxlint - https://oxc.rs/docs/guide/usage/linter/config
lint: {
plugins: ["typescript", "react", "react-perf", "jsx-a11y"],
env: {
builtin: true,
node: true,
browser: true,
},
options: {
typeAware: true,
typeCheck: true,
},
jsPlugins: [
// Plugins with "/" in name have to be aliased for now
// Issue: https://github.com/oxc-project/oxc/issues/14557
{
name: "eslint-tanstack-router",
specifier: "@tanstack/eslint-plugin-router",
},
{
name: "eslint-tanstack-query",
specifier: "@tanstack/eslint-plugin-query",
},
{ name: "vite-plus", specifier: "vite-plus/oxlint-plugin" },
],
rules: {
"vite-plus/prefer-vite-plus-imports": "warn",
"no-deprecated": "warn",
"typescript/no-floating-promises": "off",
"typescript/no-misused-spread": "off",
"jsx-a11y/prefer-tag-over-role": "off",
// Experimental:
// https://oxc.rs/docs/guide/usage/linter/rules/react/react-compiler.html
"react/react-compiler": "warn",
"eslint-tanstack-router/create-route-property-order": "warn",
"eslint-tanstack-query/exhaustive-deps": "warn",
"eslint-tanstack-query/stable-query-client": "warn",
"eslint-tanstack-query/no-rest-destructuring": "warn",
"eslint-tanstack-query/no-unstable-deps": "warn",
"eslint-tanstack-query/infinite-query-property-order": "warn",
"eslint-tanstack-query/no-void-query-fn": "warn",
"eslint-tanstack-query/mutation-property-order": "warn",
},
ignorePatterns: [
"dist",
".wrangler",
".vercel",
".netlify",
".output",
"build/",
"worker-configuration.d.ts",
"scripts/",
],
},
// Vite config - https://vite.dev/config/
define: {
__APP_VERSION__: JSON.stringify(version),
},
server: {
port: 3000,
},
plugins: lazyPlugins(() =>
mode === "test"
? []
: [
devtools({
// https://tanstack.com/devtools/latest/docs/vite-plugin#console-piping
consolePiping: { enabled: false },
}),
tanstackStart(),
// https://tanstack.com/start/latest/docs/framework/react/guide/hosting
nitro({
/**
* TODO(security): Review production security headers before deployment.
*
* App-level policies such as CSP, Permissions-Policy, X-Frame-Options /
* frame-ancestors, COOP, Referrer-Policy, and X-Content-Type-Options are
* intentionally not configured by the TanStarter template (which this project
* is based on) because safe values depend on the app's embedding requirements,
* browser APIs, integrations, and content.
*/
}),
viteReact(),
// https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md#react-compiler
babel({
presets: [reactCompilerPreset()],
}),
tailwindcss(),
],
),
}));