Fix Vite manifest paths in CI with custom normalization plugin (#285)
Commit: cf95ff130a9fa4959b64d74f1d0232548c199767
Date: 2025-09-02 22:18:50 +0200
Author: PascalHavelange
Commit Message
Fix Vite manifest paths in CI with custom normalization plugin (#285)
# Fix Vite manifest paths in CI with custom normalization plugin
## Summary
Add a custom Vite plugin to normalize manifest.json paths, ensuring consistent relative paths regardless of build environment.
## Problem
In GitHub Actions CI environment, the manifest.json was generating absolute paths:
```json
{
"../../../../actions-runner-win-x64-2.328.0/_work/inventory-app/inventory-app/resources/css/app.css": {
"file": "assets/app-YzGMk8if.css",
"src": "../../../../actions-runner-win-x64-2.328.0/_work/inventory-app/inventory-app/resources/css/app.css"
}
}
Solution
Implemented a custom Vite plugin normalize-manifest-paths
that:
- Hooks into the
generateBundle
phase - Processes the manifest.json after generation
- Normalizes all paths using regex to strip absolute path prefixes
- Ensures consistent
resources/
relative paths for both keys andsrc
values
Result
Manifest now consistently shows relative paths in all environments:
{
"resources/css/app.css": {
"file": "assets/app-YzGMk8if.css",
"src": "resources/css/app.css"
}
}
Testing
- โ Local build generates correct relative paths
- โ Build completes successfully
- โณ CI environment testing via this PR
This fix ensures Laravelโs asset helper functions work correctly regardless of build environment.
Co-authored-by: Pascal HAVELANGE havelangep@hotmail.com ```
Files Changed
- ๐ Modified:
vite.config.js
Links
This documentation was automatically generated from Git commit data.