File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { VitePWA } from "vite-plugin-pwa" ;
22import { fileURLToPath , URL } from "url" ;
3+ import fs from "fs" ;
4+ import path from "path" ;
5+ import process from "process" ;
36
47import { defineConfig } from "vite" ;
58import vue from "@vitejs/plugin-vue" ;
@@ -11,6 +14,25 @@ export default defineConfig({
1114 assetsDir : "resources" ,
1215 } ,
1316 plugins : [
17+ // Custom plugin to serve dummy-data JSON files without sourcemap injection
18+ {
19+ name : "dummy-data-json-handler" ,
20+ configureServer ( server ) {
21+ server . middlewares . use ( ( req , res , next ) => {
22+ if ( req . url ?. startsWith ( "/dummy-data/" ) ) {
23+ // Remove query parameters from URL to get the actual file path
24+ const urlWithoutQuery = req . url . split ( "?" ) [ 0 ] ;
25+ const filePath = path . join ( process . cwd ( ) , urlWithoutQuery ) ;
26+
27+ if ( fs . existsSync ( filePath ) && fs . statSync ( filePath ) . isFile ( ) ) {
28+ res . end ( fs . readFileSync ( filePath , "utf8" ) ) ;
29+ return ;
30+ }
31+ }
32+ next ( ) ;
33+ } ) ;
34+ } ,
35+ } ,
1436 vue ( ) ,
1537 VitePWA ( {
1638 registerType : "autoUpdate" ,
You can’t perform that action at this time.
0 commit comments