Commit be64c51
committed
Resolves #6809(FR-2606)
## Summary
Dev-server regression noticed after the Vite cutover: pages that mount a Monaco editor break at mount time because the `/resources/monaco/vs/*` URL prefix no longer resolves on the dev server.
`@monaco-editor/react` loads the Monaco AMD runtime at runtime via:
```ts
loader.config({ paths: { vs: '/resources/monaco/vs' } });
```
(see `react/src/helper/monacoEditor.ts`). The self-hosted prefix exists so the editor works in offline / air-gapped deployments where jsDelivr is unreachable.
Pre-Vite, the dev-server side of this contract was the `static` directory list in `react/craco.config.cjs` (lines 44–60 of the now-deleted file): it served `react/node_modules/monaco-editor/min/vs/*` at the `/resources/monaco/vs` URL prefix. Production builds copy the same tree to `build/web/resources/monaco/vs/` via the root `copymonaco` script (`package.json:32`).
After #6876 (FR-2611) dropped `craco.config.cjs`, the production `copymonaco` step was preserved but the dev-server-side mapping was not ported to `vite.config.ts`. As a result, in `pnpm run dev`, requests to `/resources/monaco/vs/loader.js` 404 and any page that mounts a Monaco editor breaks.
**Fix**: add `monacoStaticPlugin()` to `react/vite.config.ts` mirroring the deleted craco `static` entry.
- Serves `/resources/monaco/vs/*` from `react/node_modules/monaco-editor/min/vs/*`.
- `apply: 'serve'` — dev-only; production is unchanged because `copymonaco` already populates `build/web/resources/monaco/vs/`.
- Path-traversal guard via `filePath.startsWith(monacoRoot)` after `join` normalization.
- Registered in the `plugins` array before `projectRootStaticPlugin()` so the narrower Monaco prefix is matched first.
## Verification
- [x] `bash scripts/verify.sh` — Relay / Lint / Format / TypeScript all PASS
- [ ] `pnpm run dev`, navigate to a Monaco-mounting page (manifest editor on Environments page) — editor renders without console errors, no `cdn.jsdelivr.net` fetches
- [ ] DevTools → Network: `/resources/monaco/vs/loader.js`, `/resources/monaco/vs/editor/editor.main.js` return 200 from the dev server
## Stack
Top of the Vite migration follow-up stack. Sits on top of #7083 (FR-2748).
1 parent 9fa887b commit be64c51
1 file changed
Lines changed: 51 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
234 | 281 | | |
235 | 282 | | |
236 | 283 | | |
| |||
405 | 452 | | |
406 | 453 | | |
407 | 454 | | |
408 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
409 | 459 | | |
410 | 460 | | |
411 | 461 | | |
| |||
0 commit comments