Files
semantica/explorer/vite.config.ts
T
Mohd KaifandZohaib Hassnain 46447d1f3f fix(explorer): resolve blank dashboard UI and ship frontend bundle in wheel (#638)
* fix(explorer): resolve blank dashboard UI and ship frontend bundle in wheel

Fixes #631 — the Explorer server started successfully but the browser showed
a blank page because semantica/static/ was gitignored and never present after
a fresh install or clone.

Changes:
- ci.yml / release.yml: add Node 20 setup + npm ci && npm run build before
  python -m build so every wheel contains a CI-built frontend bundle
- pyproject.toml: add package-data patterns (static/*, static/assets/*) so
  setuptools includes the bundle in the wheel; add MANIFEST.in for sdist coverage
- app.py: replace silent empty-HTML fallback with a 200 page that clearly
  explains the missing bundle and links to /docs; fix CORS allow_credentials
  to default false, gated behind EXPLORER_CORS_CREDENTIALS env var to prevent
  credentialed cross-origin requests on unauthenticated endpoints
- __init__.py: warn at startup when --host is non-loopback (unauthenticated
  network exposure)
- explorer/README.md: full rewrite covering pip-install mode (primary path,
  no Node required) and dev-server mode (contributors), CLI flags, env vars,
  workspace table, troubleshooting for the blank-page symptom
- README.md: update Knowledge Explorer section with correct command and link
  to the new setup guide

* fix(explorer): set build.target esnext to fix esbuild CI failure

esbuild >=0.28 (forced via npm overrides) conflicts with Vite 6 defaults on
Linux CI — it tries to lower destructuring syntax for the implicit browser
target list but errors out. Explicit target: 'esnext' tells esbuild to emit
native syntax unchanged, bypassing the transpilation error entirely. Safe for
a developer tool that runs in modern browsers.

* test(explorer): verify packaged frontend bundle

---------

Co-authored-by: Zohaib Hassnain <109234410+ZohaibHassan16@users.noreply.github.com>
2026-06-16 14:38:24 +05:30

70 lines
1.7 KiB
TypeScript

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
// https://vite.dev/config/
export default defineConfig({
plugins: [
react({
babel: {
plugins: ['babel-plugin-react-compiler'],
},
}),
],
base: '/',
build: {
outDir: path.resolve(__dirname, '../semantica/static'),
emptyOutDir: true,
chunkSizeWarningLimit: 650,
// Explicit target avoids esbuild attempting to lower syntax that all
// modern browsers already support natively, which breaks with the
// esbuild >=0.28 override when running under Vite 6 on Linux CI.
target: 'esnext',
rollupOptions: {
output: {
manualChunks(id) {
const normalizedId = id.replaceAll('\\', '/')
if (!normalizedId.includes('node_modules')) {
return undefined
}
if (
normalizedId.includes('/node_modules/sigma/') ||
normalizedId.includes('/node_modules/graphology/') ||
normalizedId.includes('/node_modules/graphology-layout-forceatlas2/')
) {
return 'graph-vendor'
}
if (
normalizedId.includes('/node_modules/vis-data/') ||
normalizedId.includes('/node_modules/vis-timeline/')
) {
return 'timeline-vendor'
}
if (normalizedId.includes('/node_modules/@tanstack/react-query/')) {
return 'query-vendor'
}
return undefined
},
},
},
},
server: {
proxy: {
'/api': {
target: 'http://127.0.0.1:8000',
changeOrigin: true,
},
'/ws': {
target: 'ws://127.0.0.1:8000',
ws: true,
},
},
},
})