diff --git a/src/static/app/dist/index.html b/src/static/app/dist/index.html index 05433f96..f6effbbc 100644 --- a/src/static/app/dist/index.html +++ b/src/static/app/dist/index.html @@ -6,15 +6,14 @@ - - + + WGDashboard - - + +
- diff --git a/src/static/app/package.json b/src/static/app/package.json index a462118a..c24bd7f2 100644 --- a/src/static/app/package.json +++ b/src/static/app/package.json @@ -6,7 +6,7 @@ "module": "es2022", "scripts": { "dev": "vite", - "build": "vite build", + "build": "vite build && node postbuild.js", "buildcommitpush": "./build.sh", "build electron": "vite build && vite build --mode electron && cd ../../../../WGDashboard-Desktop && /opt/homebrew/bin/npm run \"electron dist\"", "preview": "vite preview" diff --git a/src/static/app/postbuild.js b/src/static/app/postbuild.js new file mode 100644 index 00000000..1b1241c8 --- /dev/null +++ b/src/static/app/postbuild.js @@ -0,0 +1,21 @@ +import fs from 'fs' +import path from 'path' + +function makePathsRelative() { + const indexPath = path.join('dist', 'index.html') + + if (!fs.existsSync(indexPath)) { + console.error('index.html not found in dist folder') + return + } + + let html = fs.readFileSync(indexPath, 'utf8') + + // Handle cases where Vite already added a base path + html = html.replace(/(href|src)="\/static\/app\/dist\//g, '$1="./static/app/dist/') + + fs.writeFileSync(indexPath, html) + console.log('✅ Converted all paths to ./static/app/dist/ in index.html') +} + +makePathsRelative() \ No newline at end of file