@@ -19,12 +19,13 @@ import { MARK_NODE } from './constants'
1919export interface BuildStaticOptions {
2020 context : DevToolsNodeContext
2121 outDir : string
22+ withApp ?: boolean
2223}
2324
2425export async function buildStaticDevTools ( options : BuildStaticOptions ) : Promise < void > {
25- const { context, outDir } = options
26+ const { context, outDir, withApp } = options
2627
27- if ( existsSync ( outDir ) )
28+ if ( ! withApp && existsSync ( outDir ) )
2829 await fs . rm ( outDir , { recursive : true } )
2930
3031 const devToolsRoot = join ( outDir , DEVTOOLS_DIRNAME )
@@ -55,24 +56,26 @@ export async function buildStaticDevTools(options: BuildStaticOptions): Promise<
5556 await fs . writeFile ( fullpath , JSON . stringify ( data , null , 2 ) , 'utf-8' )
5657 }
5758 await fs . writeFile ( resolve ( devToolsRoot , DEVTOOLS_RPC_DUMP_MANIFEST_FILENAME ) , JSON . stringify ( dump . manifest , null , 2 ) , 'utf-8' )
58- await fs . writeFile (
59- resolve ( outDir , 'index.html' ) ,
60- [
61- '<!doctype html>' ,
62- '<html lang="en">' ,
63- '<head>' ,
64- ' <meta charset="UTF-8">' ,
65- ' <meta name="viewport" content="width=device-width, initial-scale=1.0">' ,
66- ' <title>Vite DevTools</title>' ,
67- ` <meta http-equiv="refresh" content="0; url=${ DEVTOOLS_MOUNT_PATH } ">` ,
68- '</head>' ,
69- '<body>' ,
70- ` <script>location.replace(${ JSON . stringify ( DEVTOOLS_MOUNT_PATH ) } )</script>` ,
71- '</body>' ,
72- '</html>' ,
73- ] . join ( '\n' ) ,
74- 'utf-8' ,
75- )
59+ if ( ! existsSync ( resolve ( outDir , 'index.html' ) ) ) {
60+ await fs . writeFile (
61+ resolve ( outDir , 'index.html' ) ,
62+ [
63+ '<!doctype html>' ,
64+ '<html lang="en">' ,
65+ '<head>' ,
66+ ' <meta charset="UTF-8">' ,
67+ ' <meta name="viewport" content="width=device-width, initial-scale=1.0">' ,
68+ ' <title>Vite DevTools</title>' ,
69+ ` <meta http-equiv="refresh" content="0; url=${ DEVTOOLS_MOUNT_PATH } ">` ,
70+ '</head>' ,
71+ '<body>' ,
72+ ` <script>location.replace(${ JSON . stringify ( DEVTOOLS_MOUNT_PATH ) } )</script>` ,
73+ '</body>' ,
74+ '</html>' ,
75+ ] . join ( '\n' ) ,
76+ 'utf-8' ,
77+ )
78+ }
7679
7780 console . log ( c . green `${ MARK_NODE } Built DevTools to ${ relative ( context . cwd , outDir ) } ` )
7881}
0 commit comments