forked from DoDo-Project/dodo-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
45 lines (41 loc) ยท 1.2 KB
/
Copy pathvite.config.ts
File metadata and controls
45 lines (41 loc) ยท 1.2 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
import { defineConfig, type Plugin } from 'vite';
import react from '@vitejs/plugin-react-swc';
import svgr from 'vite-plugin-svgr';
import path from 'path';
import tailwindcss from '@tailwindcss/vite';
/**
* ๊ฐ๋ฐ ์๋ฒ์์ /admin/* ๊ฒฝ๋ก๋ฅผ admin.html๋ก ์๋น (๋ฐฐํฌ ํ๊ฒฝ์ vercel.json rewrites๊ฐ ๋ด๋น)
* - ์ ์ ํ์ผ ์์ฒญ(ํ์ฅ์ ์๋ ๊ฒฝ๋ก)์ ๊ทธ๋๋ก ํต๊ณผ์ํจ๋ค
*/
function adminHistoryFallback(): Plugin {
return {
name: 'admin-history-fallback',
configureServer(server) {
server.middlewares.use((req, _res, next) => {
const url = req.url ?? '';
const pathname = url.split('?')[0];
if (pathname === '/admin' || (pathname.startsWith('/admin/') && !path.extname(pathname))) {
req.url = '/admin.html';
}
next();
});
},
};
}
// https://vite.dev/config/
export default defineConfig({
plugins: [react(), svgr(), tailwindcss(), adminHistoryFallback()],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
build: {
rollupOptions: {
input: {
main: path.resolve(__dirname, 'index.html'),
admin: path.resolve(__dirname, 'admin.html'),
},
},
},
});