File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 11import { defineConfig } from 'vite'
22import * as fs from 'fs'
33import url from 'url'
4+ import path from 'path'
45
56const cdnDomain = 'http://127.0.0.2:5173'
67
@@ -21,6 +22,27 @@ export default defineConfig({
2122 next ( )
2223 } )
2324 }
25+ } ,
26+ {
27+ name : 'force-prevent-transform-assets' ,
28+ apply : 'serve' ,
29+ configureServer ( server ) {
30+ return ( ) => {
31+ server . middlewares . use ( async ( req , res , next ) => {
32+ if ( req . originalUrl != null ) {
33+ const pathname = new URL ( req . originalUrl , import . meta. url ) . pathname
34+ if ( pathname . endsWith ( '.html' ) ) {
35+ res . setHeader ( 'Content-Type' , 'text/html' )
36+ res . writeHead ( 200 )
37+ res . write ( fs . readFileSync ( path . join ( __dirname , pathname ) ) )
38+ res . end ( )
39+ }
40+ }
41+
42+ next ( )
43+ } )
44+ }
45+ }
2446 }
2547 ] ,
2648 optimizeDeps : {
You can’t perform that action at this time.
0 commit comments