-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathvite.config.ts
More file actions
121 lines (113 loc) · 2.7 KB
/
Copy pathvite.config.ts
File metadata and controls
121 lines (113 loc) · 2.7 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
import { fileURLToPath, URL } from 'node:url'
import tailwindcss from '@tailwindcss/postcss'
import react from '@vitejs/plugin-react'
import { loadEnv, defineConfig } from 'vite-plus'
import { VitePWA } from 'vite-plugin-pwa'
import packageJson from './package.json' with { type: 'json' }
const ignoredPaths = [
'.agents/**',
'**/*.md',
'build/**',
'coverage/**',
'node_modules/**',
'public/**',
'src/utils/shadcn.ts',
]
const mode =
process.env.VITEST === 'true'
? 'test'
: process.env.NODE_ENV === 'production'
? 'production'
: 'development'
const env = loadEnv(mode, process.cwd(), '')
const urlPathPrefix =
process.env.VITE_URL_PATH_PREFIX ?? env.VITE_URL_PATH_PREFIX ?? ''
const runInSurge =
(process.env.VITE_RUN_IN_SURGE ?? env.VITE_RUN_IN_SURGE) === 'true'
const isTest = process.env.VITEST === 'true'
const getBasePath = (urlPathPrefix = '') => {
if (!urlPathPrefix) {
return '/'
}
return urlPathPrefix.endsWith('/') ? urlPathPrefix : `${urlPathPrefix}/`
}
const config = defineConfig({
fmt: {
semi: false,
useTabs: false,
tabWidth: 2,
singleQuote: true,
trailingComma: 'all',
bracketSpacing: true,
printWidth: 80,
ignorePatterns: ignoredPaths,
},
lint: {
ignorePatterns: ignoredPaths,
options: {
typeAware: true,
typeCheck: true,
},
rules: {
'no-debugger': 'warn',
},
},
staged: {
'*.{js,jsx,ts,tsx}': 'vp check --fix',
},
base: getBasePath(urlPathPrefix),
css: {
postcss: {
plugins: [tailwindcss()],
},
},
plugins: [
...react(),
...(isTest
? []
: [
VitePWA({
strategies: 'injectManifest',
srcDir: 'src',
filename: 'service-worker.ts',
injectRegister: false,
manifest: false,
injectManifest: {
globPatterns: ['**/*.{js,css,html,ico,png,svg,json}'],
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
},
}),
]),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'react-virtualized': fileURLToPath(
new URL(
'./node_modules/react-virtualized/dist/commonjs/index.js',
import.meta.url,
),
),
},
},
optimizeDeps: {
include: ['react-virtualized'],
},
define: {
'import.meta.env.VITE_VERSION': JSON.stringify(packageJson.version),
},
build: {
outDir: 'build',
sourcemap: !runInSurge,
},
test: {
environment: 'jsdom',
setupFiles: ['./src/setupTests.ts'],
include: ['src/**/*.spec.{ts,tsx}'],
coverage: {
provider: 'v8',
reporter: ['text', 'html'],
},
},
})
export default config