From 308deb95e05ce21382a270216d52bb949955dd93 Mon Sep 17 00:00:00 2001 From: Bastien Wirtz Date: Sun, 17 Aug 2025 17:26:37 +0200 Subject: [PATCH] fix(dev-server): fix unparsable dummy-data fson file --- vite.config.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/vite.config.js b/vite.config.js index c8008a4..9da0c62 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,5 +1,8 @@ import { VitePWA } from "vite-plugin-pwa"; import { fileURLToPath, URL } from "url"; +import fs from "fs"; +import path from "path"; +import process from "process"; import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; @@ -11,6 +14,25 @@ export default defineConfig({ assetsDir: "resources", }, plugins: [ + // Custom plugin to serve dummy-data JSON files without sourcemap injection + { + name: "dummy-data-json-handler", + configureServer(server) { + server.middlewares.use((req, res, next) => { + if (req.url?.startsWith("/dummy-data/")) { + // Remove query parameters from URL to get the actual file path + const urlWithoutQuery = req.url.split("?")[0]; + const filePath = path.join(process.cwd(), urlWithoutQuery); + + if (fs.existsSync(filePath) && fs.statSync(filePath).isFile()) { + res.end(fs.readFileSync(filePath, "utf8")); + return; + } + } + next(); + }); + }, + }, vue(), VitePWA({ registerType: "autoUpdate",