File tree 2 files changed +19
-6
lines changed
2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 1
1
<!doctype html>
2
2
< html lang ="en ">
3
3
< head >
4
- <!-- to use with external React Dev Tools -->
5
- < script src ="http://localhost:8097 "> </ script >
4
+ <!-- REACT_DEVTOOLS_SCRIPT -->
6
5
< meta charset ="UTF-8 " />
7
6
< meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
8
7
< meta http-equiv ="Content-Security-Policy " content ="script-src 'self'; " />
Original file line number Diff line number Diff line change 1
- import { defineConfig , UserConfigExport } from 'vite'
1
+ import { defineConfig , type Plugin , type UserConfigExport } from 'vite'
2
2
import electron from 'vite-plugin-electron'
3
3
import react from '@vitejs/plugin-react-swc'
4
4
import svgr from 'vite-plugin-svgr'
@@ -24,7 +24,20 @@ const electronViteConfig: UserConfigExport = {
24
24
}
25
25
}
26
26
27
- export default defineConfig ( {
27
+ // FIXME: Potentially publish this as a dedicated plugin, if other projects
28
+ // run into the same issue
29
+ const vite_plugin_react_dev_tools : Plugin = {
30
+ name : 'react-dev-tools-replace' ,
31
+ transformIndexHtml : {
32
+ transform : ( html ) =>
33
+ html . replace (
34
+ '<!-- REACT_DEVTOOLS_SCRIPT -->' ,
35
+ '<script src="http://localhost:8097"></script>'
36
+ )
37
+ }
38
+ }
39
+
40
+ export default defineConfig ( ( { mode } ) => ( {
28
41
build : {
29
42
target : 'esnext' ,
30
43
outDir : 'build'
@@ -51,6 +64,7 @@ export default defineConfig({
51
64
onstart : ( { reload } ) => reload ( )
52
65
}
53
66
] ) ,
54
- svgr ( )
67
+ svgr ( ) ,
68
+ mode !== 'production' && vite_plugin_react_dev_tools
55
69
]
56
- } )
70
+ } ) )
You can’t perform that action at this time.
0 commit comments