-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathvite.server.config.js
More file actions
35 lines (33 loc) · 864 Bytes
/
Copy pathvite.server.config.js
File metadata and controls
35 lines (33 loc) · 864 Bytes
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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import fs from 'fs';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export default defineConfig({
plugins: [
react(),
{
name: 'rename-index',
closeBundle() {
// Rename index-server.html to index.html after build
const oldPath = path.join(__dirname, 'dist-server', 'index-server.html');
const newPath = path.join(__dirname, 'dist-server', 'index.html');
if (fs.existsSync(oldPath)) {
fs.renameSync(oldPath, newPath);
}
}
}
],
server: {
allowedHosts: true
},
build: {
outDir: 'dist-server',
rollupOptions: {
input: {
main: path.resolve(__dirname, 'index-server.html')
}
}
}
});