-
Notifications
You must be signed in to change notification settings - Fork 45
/
vite.main.config.ts
101 lines (99 loc) · 2.52 KB
/
vite.main.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
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
import type { ConfigEnv, UserConfig } from 'vite'
import { defineConfig, mergeConfig } from 'vite'
import { configDefaults } from 'vitest/config'
import viteTsconfigPaths from 'vite-tsconfig-paths'
import vitePluginEslint from '@nabla/vite-plugin-eslint'
import vitePluginPackageVersion from 'vite-plugin-package-version'
import {
getBuildConfig,
getBuildDefine,
external,
pluginHotRestart,
} from './vite.base.config'
import viteJsPluginReact from '@vitejs/plugin-react'
// @ts-ignore: No types available
import { lezer } from '@lezer/generator/rollup'
// https://vitejs.dev/config
export default defineConfig((env) => {
const forgeEnv = env as ConfigEnv<'build'>
const { forgeConfigSelf } = forgeEnv
const define = getBuildDefine(forgeEnv)
const config: UserConfig = {
server: {
open: true,
port: 3000,
watch: {
ignored: [
'**/target/**',
'**/dist/**',
'**/build/**',
'**/test-results/**',
'**/playwright-report/**',
],
},
},
test: {
globals: true,
pool: 'forks',
poolOptions: {
forks: {
maxForks: 2,
minForks: 1,
},
},
setupFiles: ['src/setupTests.ts', '@vitest/web-worker'],
environment: 'happy-dom',
coverage: {
provider: 'v8',
},
exclude: [...configDefaults.exclude, '**/e2e/**/*'],
deps: {
optimizer: {
web: {
include: ['vitest-canvas-mock'],
},
},
},
clearMocks: true,
restoreMocks: true,
mockReset: true,
reporters: process.env.GITHUB_ACTIONS
? ['dot', 'github-actions']
: ['verbose', 'hanging-process'],
testTimeout: 1000,
hookTimeout: 1000,
teardownTimeout: 1000,
},
build: {
lib: {
entry: forgeConfigSelf?.entry ?? 'src/main.ts',
fileName: () => '[name].js',
formats: ['cjs'],
},
rollupOptions: {
external,
},
},
resolve: {
// Load the Node.js entry.
mainFields: ['module', 'jsnext:main', 'jsnext'],
alias: {
'@kittycad/codemirror-lsp-client':
'/packages/codemirror-lsp-client/src',
},
},
plugins: [
pluginHotRestart('restart'),
viteJsPluginReact(),
viteTsconfigPaths(),
vitePluginEslint(),
vitePluginPackageVersion(),
lezer(),
],
worker: {
plugins: () => [viteTsconfigPaths()],
},
define,
}
return mergeConfig(getBuildConfig(forgeEnv), config)
})