WP SSR Framework uses Vite as the build tool and asset pipeline for the React SPA. The PHP side, through theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Ahondev/portfolio-v2/llms.txt
Use this file to discover all available pages before exploring further.
Vite class, automatically detects whether you are in development (using the Vite dev server with hot module replacement) or production (reading hashed filenames from a build manifest). You never need to hard-code asset URLs.
How PHP Serves Vite Assets
TheVite singleton class (src/SSR/Vite.php) resolves the correct asset URLs for each environment.
Development Mode
When Vite’s dev server is running, it writes the server URL to apublic/hot file. The PHP Vite class reads this file to detect development mode:
src/SSR/Vite.php
Vite::instance()->assets() returns:
Production Mode
In production,public/hot does not exist. Instead, Vite reads the Vite build manifest at dist/.vite/manifest.json and caches it as a WordPress transient for 24 hours:
src/SSR/Vite.php
Vite::instance()->assets() reads the index.html entry from the manifest and returns:
js and css paths are prefixed with /client/dist/ and taken directly from the manifest’s index.html entry. If the manifest is missing or has no index.html key, both arrays are empty.
The Vite class is used by WebController::view() to inject the correct <script> and <link> tags into every HTML response.
vite.config.ts
The Vite configuration in web/client/vite.config.ts:
vite.config.ts
@/alias — maps toweb/client/src/. Use@/components/Buttoninstead of relative paths.manifest: true— required for PHP to read hashed filenames in production.- Port 8080 — the Vite dev server runs on port 8080; the WordPress dev server on port 8888.
hotFilePlugin— a custom Vite plugin that writespublic/hotwhen the dev server starts and removes it on exit. This is the signal PHP uses to switch to dev mode.
The hotFilePlugin
The hotFilePlugin is defined at the bottom of vite.config.ts. On dev server start it:
- Deletes any existing
public/hotfile (cleanup from a previous crash) - Writes
http://localhost:8080topublic/hot - Registers
process.on('exit')and signal handlers (SIGINT,SIGTERM,SIGHUP) to delete the file on shutdown
vite.config.ts
Development Workflow
Start the Vite dev server
In a separate terminal:This starts Vite on
http://localhost:8080 and writes web/client/public/hot.The
hotFilePlugin automatically deletes public/hot when you stop the Vite dev server (Ctrl+C). If the file is left behind after a crash, PHP will attempt to load assets from the dead dev server. Delete web/client/public/hot manually in that case.Production Build
web/client/dist/:
index.html entry to find the main JS and CSS files:
dist/.vite/manifest.json
HTML Shell (src/SSR/client.php)
The PHP template that renders the HTML document for every page request. It:
- Sets
window.__wp_data__,window.__wp_view__, andwindow.__wp_seo__as an inline script - Injects the Vite CSS
<link>tags - Renders
<div id="root"></div>— the React mount point - Injects the Vite JS
<script>tags (either from dev server or production manifest)