Refactor Vite manifest normalization plugin (#287)
Commit: 1db1def86da75f8745c0cdb4cb404fe67e1de884
Date: 2025-09-02 23:01:59 +0200
Author: PascalHavelange
Commit Message
Refactor Vite manifest normalization plugin (#287)
# Refactor Vite manifest normalization plugin for better maintainability
## Changes Made
- **Simplified normalization logic**: Replaced verbose imperative code with a clean `normalizePath` function that handles both Windows and Unix paths using `Math.max()`
- **Functional programming approach**: Used `Object.fromEntries()` and `map()` instead of manual loops for cleaner code
- **Reduced complexity**: Condensed ~50 lines of code down to ~25 lines while maintaining identical functionality
- **Better readability**: The plugin logic is now much easier to understand and maintain
## Technical Details
The refactored plugin:
- Uses a single `normalizePath` function that finds the last occurrence of either `resources/` or `resources\`
- Normalizes backslashes to forward slashes for consistent paths
- Efficiently detects changes to avoid unnecessary file writes
- Maintains the same behavior for both local development (already normalized paths) and CI environments (absolute paths)
## Testing
- Verified the plugin still executes correctly during builds
- Tested path normalization logic with various absolute path formats
- Confirmed the refactored code produces identical results to the original implementation
This refactoring improves code maintainability without changing functionality, making the manifest normalization plugin easier to understand and modify in the future.
Co-authored-by: Pascal HAVELANGE <havelangep@hotmail.com>
Files Changed
- 📝 Modified:
vite.config.js
Links
This documentation was automatically generated from Git commit data.