@ungic/web
v0.7.0
Published
Builds a Site's app frontends from its theme: compiles theme/screens with the ungic compiler, mounts them on the web runtime and bundles each app with Vite (buildApps / devApps).
Readme
@ungic/web
Builds a Site's app frontends from its theme. ungic exports a theme into the Site's theme/ folder (screens,
components, design, locales, assets and one theme/apps/<id>/app.json per app); this package compiles those screens
with the ungic compiler, mounts them on the ungic web runtime per app (its start screen, tabs, guards, screens and
design) and bundles each app with Vite into a static folder.
Most Sites never call it directly: the ungic CLI builds and serves the apps (ungic build, ungic dev).
import { buildApps, devApps } from '@ungic/web';
// Production: dist/apps/<appId>/ (index.html + hashed assets, PWA manifest, icons, service worker)
const { apps } = await buildApps({ root: process.cwd(), out: 'dist/apps' });
// Development: Vite dev servers that recompile when theme/ changes
const dev = await devApps({ root: process.cwd(), httpServer }); // then route requests through dev.handle(req, res, next)- One app is served at
/, several at/<id>/(thebaseoption changes it). ssr: true(or a list of app ids) also builds a server bundle per app intossrOut(defaultdist/ssr/<id>/:entry.mjs+template.html).render(request, { api })fromentry.mjsanswers a page as HTML (the start screen, or the screen the URL names; data loaded throughapias the visitor; title / description from the screen'smetaexport) that the browser hydrates, or the single-page shell when rendering fails.devAppsrenders the same pages through Vite.ssrEntriesOf(result, root)lists the entries.prerender: { <app>: true | ['/', '/about'] }(anssrapp) writes those pages as static HTML into the app's folder, rendered as a signed-out visitor throughprerenderApi(the Site's API; without it a page that reads rows is skipped, never written with empty lists).BuiltApp.prerenderedlists the pages and the skipped ones with the reason;prerenderApps(result.apps, { prerender, api })does the same after a build.- Every API request of an app carries
X-Ungic-App: <id>, so the CMS applies that app's role check. - Rendering PNG icons uses
sharpwhen installed (an optional peer;@ungic/cmsbrings it), else an SVG icon.
Documentation
- Apps built from theme/: the build, server rendering, prerendered pages.
- Apps: several apps per Site, routing by path or host.
- Projects exported from ungic: what the
theme/folder holds. - Ungic CMS documentation.
License: Apache-2.0.
