Critical: Static Hosting Path
This project is statically hosted at the subdirectory `/hyphon/` (e.g., `[suspicious link removed]`).
1. Vite Configuration
The `base` path in `vite.config.ts` must always remain set to relative (`./`) or explicitly `/hyphon/` to ensure assets load correctly in the subdirectory.
```
export default defineConfig({
base: './', // DO NOT CHANGE to '/'
// ...
});
```
2. Asset & Worker Loading
Never use absolute paths (e.g., `/file.wasm`) for fetching resources, initializing Workers, or loading audio files. You MUST use `import.meta.env.BASE_URL` to prepend the correct base path.
Correct Patterns:
```
// Fetching WASM/JSON
fetch(import.meta.env.BASE_URL + 'rubberband.wasm');
// Initializing Workers
new Worker(import.meta.env.BASE_URL + 'hyphon_native.js');
// Audio URLs
const audioUrl = import.meta.env.BASE_URL + 'presets/saw.wav';
```
Incorrect Patterns (Will Cause 404s):
```
fetch('/rubberband.wasm'); // Fails at /hyphon/
new Worker('/hyphon_native.js'); // Fails
```
3. AudioWorklets & DSP
AudioWorklets cannot access `import.meta.env` directly. Pass the `wasmBinary` or resolved URLs from the main thread via `postMessage` during initialization.
---
Keep this configuration active indefinitely.