Skip to content

Commit 522cacb

Browse files
kamilkisielan1ru4l
authored andcommitted
Add react-scan in local development mode
1 parent 5be1e97 commit 522cacb

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

packages/web/app/vite.config.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
import { resolve } from 'node:path';
2-
import type { UserConfig } from 'vite';
2+
import type { Plugin, UserConfig } from 'vite';
33
import tsconfigPaths from 'vite-tsconfig-paths';
44
import react from '@vitejs/plugin-react';
55

66
const __dirname = new URL('.', import.meta.url).pathname;
77

8+
// Add react-scan in local development mode
9+
const reactScanPlugin: Plugin = {
10+
name: 'react-scan',
11+
transformIndexHtml(html, ctx) {
12+
if (ctx.server?.config.command === 'serve') {
13+
return html.replace(
14+
'<head>',
15+
'<head><script src="https://unpkg.com/react-scan/dist/auto.global.js"></script>',
16+
);
17+
}
18+
19+
return html;
20+
},
21+
};
22+
823
export default {
924
root: __dirname,
10-
plugins: [tsconfigPaths(), react()],
25+
plugins: [tsconfigPaths(), react(), reactScanPlugin],
1126
build: {
1227
rollupOptions: {
1328
input: {

0 commit comments

Comments
 (0)