-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
95 lines (93 loc) · 2.46 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/// <reference types="vitest" />
import react from '@vitejs/plugin-react-swc';
import path from 'path';
import { defineConfig } from 'vite';
import mkcert from 'vite-plugin-mkcert';
function fixCssRoot() {
return {
postcssPlugin: 'postcss-fix-nested-root',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Once(root: any) {
root.walkRules((rule: { selector: string }) => {
if (rule.selector.includes(' :root')) {
rule.selector = rule.selector.replace(' :root', '');
}
});
},
};
}
fixCssRoot.postcss = true;
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
define: {
'globalThis.__DEV__': JSON.stringify(mode !== 'production'),
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@Contexts': path.resolve(__dirname, './src/components/Contexts'),
'@Telescope': path.resolve(__dirname, './src/components/Panels/Telescope'),
'@WavefrontSensors': path.resolve(__dirname, './src/components/Panels/WavefrontSensors'),
'@Guider': path.resolve(__dirname, './src/components/Panels/Guider'),
'@Shared': path.resolve(__dirname, './src/components/Shared'),
'@assets': path.resolve(__dirname, './src/assets'),
'@gql': path.resolve(__dirname, './src/gql'),
},
},
build: {
outDir: 'dist/navigate-ui',
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('primereact')) return 'prime';
},
},
},
},
server: {
host: '0.0.0.0',
proxy: {
'^/navigate/graphql': {
target: 'http://navigate.lucuma.xyz:9070',
changeOrigin: true,
},
'^/db': {
target: 'http://navigate.lucuma.xyz:4000',
changeOrigin: true,
},
'^/odb': {
target: 'https://lucuma-postgres-odb-dev.herokuapp.com',
changeOrigin: true,
},
'^/navigate/ws': {
target: 'ws://localhost:9070',
changeOrigin: true,
ws: true,
},
},
},
preview: {
host: '0.0.0.0',
},
css: {
preprocessorOptions: {
scss: {
charset: false,
},
},
postcss: {
plugins: [fixCssRoot()],
},
},
plugins: [react({}), mkcert({ hosts: ['localhost', 'local.lucuma.xyz', 'navigate.lucuma.xyz'] })],
test: {
globals: true,
setupFiles: ['vitest-browser-react'],
browser: {
enabled: true,
name: 'chromium',
provider: 'playwright',
},
},
base: '/',
}));