-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
30 lines (28 loc) · 1019 Bytes
/
vite.config.js
File metadata and controls
30 lines (28 loc) · 1019 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
import { defineConfig } from 'vite';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export default defineConfig({
root: 'public',
server: {
host: '0.0.0.0',
},
plugins: [
{
name: 'serve-storage-state',
configureServer(server) {
server.middlewares.use('/tests/storage-state.json', (req, res) => {
const filePath = path.resolve(__dirname, 'tests', 'storage-state.json');
if (fs.existsSync(filePath)) {
res.setHeader('Content-Type', 'application/json');
res.end(fs.readFileSync(filePath, 'utf-8'));
} else {
res.statusCode = 404;
res.end(JSON.stringify({ error: 'storage-state.json not found' }));
}
});
},
},
],
});