Cleaned up public-app vite configs (.js → .jsx + dead preview/loader cruft)#28973
Conversation
#28968 dropped the public-app preview servers in favor of a plain `vite build --watch` dev loop, so the configurePreviewServer no-op plugin added in #28964 and the `preview` block (host/port/allowedHosts) no longer have a consumer. - removed the tolerateMissingOutDir plugin definition + its plugins[] entry - removed the preview block The five peer public-app configs (portal/announcement-bar/comments-ui/ sodo-search/signup-form) also still carry dead preview blocks; those are folded into a later commit in the same PR.
no ref Two long-stable identifiers in apps/portal and apps/sodo-search trigger the `credential assignment` rule but are not secrets: - `scriptTag.dataset.key` (portal/src/index — DOM variable reference, not a literal value at all) - `69010382388f9de5869ad6e558` (sodo-search test fixture API key, in tree since #25461 and used purely to assert the App component receives the prop) Neither has tripped the hook historically because the files weren't staged in any commit since the rule was tightened. A follow-up rename commit (.js → .jsx for JSX-containing files) re-stages both, so add allowlist entries now to keep the rule green for future edits too.
no ref Long-standing convention drift: portal, announcement-bar and sodo-search had JSX in plain .js files (~77 across src + test), worked around by two esbuild loader overrides in each vite.config — a global `esbuild.loader: 'jsx'` over /src|test\.jsx?$/ and an `optimizeDeps` plugin that load-files-as-jsx on the .js subset. Renaming the files to match their content lets esbuild infer the loader from the extension and lets both hacks be dropped in a follow-up commit. - 39 portal src + 28 portal test files - 5 announcement-bar src files - 3 sodo-search src + 2 test files - 3 vite.config entry paths updated (announcement-bar/portal/sodo-search hardcoded `src/index.js`) - 5 portal test files updated to drop the explicit '.js' from `../src/app.js` imports (extensionless lets Vite resolve to the new .jsx file) Verified: bundle .js + .css are byte-identical to pre-rename baselines across all 6 public apps; sourcemaps reference the new .jsx filenames in their `sources` arrays (expected, not a runtime change).
no ref
With JSX-containing files now correctly named .jsx (previous commit),
the explicit loader overrides in portal, announcement-bar and
sodo-search vite.configs are redundant — esbuild infers the right
loader from the extension. Removed:
- the `esbuild: {loader: 'tsx'|'jsx', include: /...\.jsx?$/}` block
- the `optimizeDeps.esbuildOptions.plugins[load-js-files-as-jsx]`
inline plugin that re-loaded .js files as jsx during dep prebundling
- the now-unused `fs/promises` import each of those needed
### Bundle drift (benign)
Bundle .js shrinks ~300 bytes in portal (0.012%) and stays the same
size in sodo-search (different hash). The drift comes from esbuild's
default per-extension loader emitting subtly different output than the
TSX-loader-on-everything override that used to apply — semantically
identical, no behavior change. Verified by running each app's full
test suite:
- portal: 582 passed, 1 skipped
- sodo-search: 11 passed
- announcement-bar: 1 passed
admin-toolbar, comments-ui and signup-form bundle output is unchanged
(byte-identical to baseline).
no ref Continuation of commit 71af77c (admin-toolbar cleanup). With #28968 having dropped the public-app preview-server flow in favor of `vite build --watch` plus Caddy-served UMDs, the per-app `preview: {host, allowedHosts, port, cors}` blocks no longer have a consumer. Removed from: - portal (plus its dead `server: {port: 5368}` block — no vite dev script consumes it) - announcement-bar - sodo-search comments-ui and signup-form intentionally kept their `preview` blocks — each has a `dev:test` script that still invokes `vite preview` and relies on `host: '0.0.0.0'` / `allowedHosts` for the Playwright acceptance flow.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (3)
WalkthroughMultiple Vite configuration files across Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run-many --target=build --projects=tag:publi... |
✅ Succeeded | 3s | View ↗ |
nx run-many -t test:unit -p @tryghost/admin-too... |
✅ Succeeded | 57s | View ↗ |
nx run-many -t lint -p ghost-monorepo,@tryghost... |
✅ Succeeded | 19s | View ↗ |
nx run @tryghost/admin:build |
✅ Succeeded | 6s | View ↗ |
nx run ghost:build:assets |
✅ Succeeded | 2s | View ↗ |
nx run ghost:build:tsc |
✅ Succeeded | 6s | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-06-29 21:04:44 UTC
no ref The earlier commits in this PR (vite config cleanup, .js → .jsx rename, esbuild hack removal) trigger the app-version-bump CI check for the apps whose files changed. Patch-only bumps; MAJOR.MINOR in ghost/core/core/shared/config/defaults.json is unchanged. - admin-toolbar: 0.1.9 → 0.1.10 - announcement-bar: 1.1.25 → 1.1.26 - portal: 2.69.13 → 2.69.14 - sodo-search: 1.8.28 → 1.8.29 comments-ui and signup-form had no file changes, no bump needed.
The merge of main into this branch brought in #28973, which bumped sodo-search to 1.8.29 and announcement-bar to 1.1.26 — matching the values this PR had already bumped to. check-app-version-bump.js then fails because the PR is no longer ahead of main on those two apps. Bump both patches once more. - sodo-search: 1.8.29 -> 1.8.30 - announcement-bar: 1.1.26 -> 1.1.27 no ref

Summary
Frontend (public-app) vite config prep — pure cleanup, no behavior change. Continues #28968, which moved the public apps to a
vite build --watch-only dev loop (no preview servers, no upfront build).Sets the stage for a follow-up PR that extracts a shared helper at
apps/_shared/vite-public-app.tsfor the 6 public-app vite configs.Commits
Removed dead
tolerateMissingOutDirplugin + preview block from admin-toolbar (71af77c222) — Cleaned up public-app dev scripts #28968 dropped the preview server flow, leaving the no-op plugin from Changed admin-toolbar dev to opt out of vite preview's outDir guard via plugin #28964 and thepreview: {host, allowedHosts, port: 4176}block with no consumer.Added secretlint allowlist entries (483e20771b) — Two pre-existing patterns (
scriptTag.dataset.keyDOM reference in portal; a fake-hex test fixture API key in sodo-search) trip thecredential assignmentrule once their files are re-staged by the following commit.Renamed JSX-containing .js files to .jsx (5ab602327b) — 101 files across portal/announcement-bar/sodo-search where JSX was hidden behind a
.jsextension and worked around by per-app esbuild loader overrides. Also: 3 vite.config entry paths and 5 portal test files' explicit'../src/app.js'imports.Removed esbuild jsx-loader hacks (1e26a9d1aa) — With the rename in place, esbuild infers the right loader per extension. Dropped the
esbuild: {loader: 'tsx'|'jsx', include: /...\.jsx?$/}block + theoptimizeDeps.esbuildOptions.plugins[load-js-files-as-jsx]inline plugin + the now-unusedfs/promisesimport from portal/announcement-bar/sodo-search configs.Removed dead preview/server blocks from 3 more configs (3cb7b17047) — portal, announcement-bar, sodo-search. comments-ui and signup-form intentionally kept their
preview:blocks — both have adev:testscript that still callsvite previewand may rely on thehost: '0.0.0.0'/allowedHostssettings for the Playwright flow.Verification
.jsxfilenames insourcesarrays (expected, not a runtime change).Test plan
pnpm devfrom a clean clone — verify all 6 public apps build, no preview-server crashes