-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvite.config.ts
45 lines (42 loc) · 1.45 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
/**
* 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 eslint from 'vite-plugin-eslint';
import svgr from 'vite-plugin-svgr';
import tsconfigPaths from 'vite-tsconfig-paths';
const serverSettings: CommonServerOptions = {
port: 3004,
proxy: {
'/api/gateway': {
target: 'http://localhost:9000',
rewrite: (path: string) => path.replace(/^\/api\/gateway/, ''),
},
'/ws/gateway': {
target: 'http://localhost:9000',
rewrite: (path: string) => path.replace(/^\/ws\/gateway/, ''),
ws: true,
},
},
};
export default defineConfig((config) => ({
plugins: [
react(),
eslint({
failOnWarning: config.mode !== 'development',
lintOnStart: true,
}),
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',
},
}));