File tree Expand file tree Collapse file tree 1 file changed +16
-18
lines changed Expand file tree Collapse file tree 1 file changed +16
-18
lines changed Original file line number Diff line number Diff line change @@ -159,25 +159,23 @@ function vitePluginWasmPack(
159159 } ,
160160
161161 configureServer ( { middlewares } ) {
162- return ( ) => {
163- // send 'root/pkg/xxx.wasm' file to user
164- middlewares . use ( ( req , res , next ) => {
165- if ( isString ( req . url ) ) {
166- const basename = path . basename ( req . url ) ;
167- res . setHeader (
168- 'Cache-Control' ,
169- 'no-cache, no-store, must-revalidate'
170- ) ;
171- const entry = wasmMap . get ( basename ) ;
172- if ( basename . endsWith ( '.wasm' ) && entry ) {
173- res . writeHead ( 200 , { 'Content-Type' : 'application/wasm' } ) ;
174- fs . createReadStream ( entry . path ) . pipe ( res ) ;
175- } else {
176- next ( ) ;
177- }
162+ // send 'root/pkg/xxx.wasm' file to user
163+ middlewares . use ( ( req , res , next ) => {
164+ if ( isString ( req . url ) ) {
165+ const basename = path . basename ( req . url ) ;
166+ res . setHeader (
167+ 'Cache-Control' ,
168+ 'no-cache, no-store, must-revalidate'
169+ ) ;
170+ const entry = wasmMap . get ( basename ) ;
171+ if ( basename . endsWith ( '.wasm' ) && entry ) {
172+ res . writeHead ( 200 , { 'Content-Type' : 'application/wasm' } ) ;
173+ fs . createReadStream ( entry . path ) . pipe ( res ) ;
174+ } else {
175+ next ( ) ;
178176 }
179- } ) ;
180- } ;
177+ }
178+ } ) ;
181179 } ,
182180
183181 buildEnd ( ) {
You can’t perform that action at this time.
0 commit comments