fix: Generate Vite manifest for customer SPA loading

Problem: Customer SPA stuck on 'Loading...' message after installation
Root Cause: Vite build wasn't generating manifest.json, causing WordPress asset loader to fall back to direct app.js loading without proper module configuration

Solution:
1. Added manifest: true to both SPA vite configs
2. Updated Assets.php to look for manifest in correct location (.vite/manifest.json)
3. Rebuilt both SPAs with manifest generation

Changes:
- customer-spa/vite.config.ts: Added manifest: true
- admin-spa/vite.config.ts: Added manifest: true
- includes/Frontend/Assets.php: Updated manifest path from 'manifest.json' to '.vite/manifest.json'

Build Output:
- Customer SPA: dist/.vite/manifest.json generated
- Admin SPA: dist/.vite/manifest.json generated
- Production zip: 10M (includes manifest files)

Result:
 Customer SPA now loads correctly via manifest
 Admin SPA continues to work
 Proper asset loading with CSS and JS from manifest
 Production package ready for deployment
This commit is contained in:
Dwindi Ramadhana
2025-12-30 17:26:18 +07:00
parent f1bab5ec46
commit 447ca501c7
3 changed files with 4 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ export default defineConfig({
build: {
outDir: 'dist',
emptyOutDir: true,
manifest: true,
rollupOptions: {
input: { app: 'src/main.tsx' },
output: { entryFileNames: 'app.js', assetFileNames: 'app.[ext]' }

View File

@@ -43,6 +43,7 @@ export default defineConfig({
build: {
outDir: 'dist',
emptyOutDir: true,
manifest: true,
rollupOptions: {
input: { app: 'src/main.tsx' },
output: { entryFileNames: 'app.js', assetFileNames: 'app.[ext]' }

View File

@@ -75,8 +75,8 @@ class Assets {
return;
}
// Load manifest to get hashed filenames
$manifest_file = $dist_path . 'manifest.json';
// Load manifest to get hashed filenames (Vite puts it in .vite/manifest.json)
$manifest_file = $dist_path . '.vite/manifest.json';
if (file_exists($manifest_file)) {
$manifest = json_decode(file_get_contents($manifest_file), true);