-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvite.config.ts
More file actions
66 lines (59 loc) · 2.29 KB
/
Copy pathvite.config.ts
File metadata and controls
66 lines (59 loc) · 2.29 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
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import react from '@vitejs/plugin-react';
import { CommonServerOptions, defineConfig } from 'vite';
import checker from 'vite-plugin-checker';
import svgr from 'vite-plugin-svgr';
import tsconfigPaths from 'vite-tsconfig-paths';
const serverSettings: CommonServerOptions = {
port: 3000,
proxy: {
'/api/gateway': {
target: 'http://localhost:9000',
rewrite: (url: string) => url.replace(/^\/api\/gateway/, ''),
},
'/ws/gateway': {
target: 'http://localhost:9000',
rewrite: (url: string) => url.replace(/^\/ws\/gateway/, ''),
ws: true,
},
},
};
export default defineConfig((_config) => ({
plugins: [
react(),
process.env.VITE_CHECKER_ENABLED === 'true' &&
checker({
// TypeScript checking
typescript: true,
// ESLint checking
eslint: {
useFlatConfig: true,
lintCommand: 'eslint . --max-warnings 0',
dev: {
logLevel: ['error', 'warning'],
},
watchPath: './src',
},
overlay: false, // Disable overlay in browser
// Show errors in terminal
terminal: true,
// Disable during build because vite-plugin-checker runs checks in a parallel worker,
// which doesn't block the build if linting or type checking fails. To ensure build
// failure on errors, we use the 'prebuild' script instead (runs before 'npm run build').
enableBuild: false,
}),
svgr(), // works on every import with the pattern "**/*.svg?react"
tsconfigPaths(), // to resolve absolute path via tsconfig cf https://stackoverflow.com/a/68250175/5092999
],
base: './',
server: serverSettings, // for npm run start
preview: serverSettings, // for npm run serve (use local build)
build: {
outDir: 'build',
},
}));