-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
65 lines (63 loc) · 1.61 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
import { createLogger, defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import UnoCSS from 'unocss/vite';
import { createMpaPlugin } from 'vite-plugin-virtual-mpa';
import { fileURLToPath, URL } from 'node:url';
import type { Logger } from 'vite';
const customLogger = (): Logger => {
const logger = createLogger();
return {
...logger,
warn: (message, options) => {
const regexp = new RegExp('files in the public directory are served at the root path.', 'g');
if (regexp.test(message)) return;
logger.info(message, options);
},
};
};
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
UnoCSS(),
createMpaPlugin({
verbose: false,
template: 'public/index.html',
pages: [{ name: 'index', filename: 'index.html' }],
rewrites: [{ from: /^(?!.*charting_library).*$/i, to: '/public/index.html' }],
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
customLogger: customLogger(),
css: {
transformer: 'lightningcss',
},
server: {
open: true,
cors: false,
proxy: {
'/api': {
target: 'http://jsonplaceholder.typicode.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
'/socket.io': {
target: 'ws://localhost:5174',
ws: true,
},
},
},
build: {
rollupOptions: {
output: {
assetFileNames: '[ext]/[name]-[hash].[ext]',
chunkFileNames: 'js/[name]-[hash].js',
entryFileNames: 'js/[name]-[hash].js',
},
},
},
});