Skip to content

Commit 4c85742

Browse files
committed
feat(config): Implement plugin to serve public assets at basePath in development
This commit introduces a new Vite plugin that rewrites requests for public assets from the basePath to the root, enhancing the development experience by simplifying asset access. The previous proxy configuration has been removed in favor of this more streamlined approach.
1 parent 911c8a7 commit 4c85742

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

www/vocs.config.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1+
import type { Plugin } from 'vite';
12
import { defineConfig } from 'vocs';
23

4+
// Plugin to serve public assets at basePath in dev mode
5+
function servePublicAtBasePath(): Plugin {
6+
return {
7+
name: 'serve-public-at-basepath',
8+
configureServer(server) {
9+
server.middlewares.use((req, res, next) => {
10+
// Rewrite requests from basePath to root for public assets
11+
if (req.url?.startsWith('/zkevm-benchmark-workload/marginal-gas-benchmark/')) {
12+
req.url = req.url.replace('/zkevm-benchmark-workload', '');
13+
}
14+
next();
15+
});
16+
},
17+
};
18+
}
19+
320
export default defineConfig({
421
basePath: '/zkevm-benchmark-workload',
522
rootDir: './docs',
623
vite: {
7-
server: {
8-
// Serve public assets at basePath in dev mode
9-
proxy: {
10-
'/zkevm-benchmark-workload/marginal-gas-benchmark': {
11-
target: 'http://localhost:5173',
12-
rewrite: (path) => path.replace(/^\/zkevm-benchmark-workload/, ''),
13-
},
14-
},
15-
},
24+
plugins: [servePublicAtBasePath()],
1625
},
1726
title: 'zkGas profiling',
1827
description: 'Comprehensive profiling framework for measuring and comparing the resources needed for proving different OPCODEs in zk environments across various gas categories.',

0 commit comments

Comments
 (0)