@@ -120,10 +120,7 @@ export default function UserscriptPlugin(
120120 const userFilePath = resolve ( rootDir , outDir , userFilename )
121121 const proxyFilePath = resolve ( rootDir , outDir , proxyFilename )
122122 const metaFilePath = resolve ( rootDir , outDir , metaFilename )
123- const hotReloadPath = resolve (
124- workdir ,
125- `hot-reload-${ config . header . name } .js`
126- )
123+ const wsPath = resolve ( workdir , `ws-${ config . header . name } .js` )
127124
128125 try {
129126 let source = readFileSync ( outPath , 'utf8' )
@@ -141,25 +138,22 @@ export default function UserscriptPlugin(
141138 )
142139
143140 if ( isBuildWatch ) {
144- const hotReloadFile = readFileSync (
145- resolve ( workdir , 'hot-reload.js' ) ,
146- 'utf8'
147- )
141+ const wsFile = readFileSync ( resolve ( workdir , 'ws.js' ) , 'utf8' )
148142
149- const hotReloadScript = await transform ( {
150- file : hotReloadFile . replace ( '__WS__' , `ws://localhost:${ port } ` ) ,
151- name : hotReloadPath ,
143+ const wsScript = await transform ( {
144+ file : wsFile . replace ( '__WS__' , `ws://localhost:${ port } ` ) ,
145+ name : wsPath ,
152146 loader : 'js'
153147 } )
154148
155- writeFileSync ( hotReloadPath , hotReloadScript )
149+ writeFileSync ( wsPath , wsScript )
156150 writeFileSync (
157151 proxyFilePath ,
158152 new Banner ( {
159153 ...config . header ,
160154 require : [
161155 ...config . header . require ! ,
162- 'file://' + hotReloadPath ,
156+ 'file://' + wsPath ,
163157 'file://' + outPath
164158 ]
165159 } ) . generate ( )
0 commit comments