Skip to content

Frontend Build & Theme Bridge Detail

Reference for how the frontend (built in middag-io/ui/middag-io/framework, consumed by the Moodle adapter) packages itself for the Moodle host: Moodle-native AMD build output and Moodle theme-color inheritance. Backs MDL-019.

AMD chunk table

ChunkContentsLoading
middag-app.min.jsEntry + app code + registriesImmediate
react-vendor-lazy.min.jsreact, react-dom, @inertiajs/reactLazy
react-ui-lazy.min.jsRadix UI primitivesLazy
react-table-lazy.min.jsTanStack TableLazy
middag-ext-{slug}.min.jsExtension chunks (non-core, via CDN)Lazy

The immediately-loaded entry stays small; everything else — the React runtime, UI primitives, the table library, and non-core extension bundles — loads lazily, on demand, through Moodle's native requirejs.php mechanism.

The moodle-amd Vite plugin

ResponsibilityDetail
Path rewritingRewrites relative import paths between compiled chunks into the local_middag/{name} format Moodle's AMD/RequireJS loader expects
Dev-mode duplicationDuplicates build output into amd/src/, so a single watch process covers both amd/build/ and amd/src/ instead of two separate processes running side by side

Output goes directly into amd/build/ — no generic bundler target requiring a manual repackaging step afterward.

Theme bridge mechanics

StepDetail
Read$PAGE->theme->settings->brandcolor is read server-side
InjectThe value is injected as the --middag-brand CSS custom property in <head>
MapTailwind's semantic tokens (--primary and siblings) reference --middag-brand conditionally
GateControlled by the local_middag/inherit_theme_colors admin checkbox — off means the product's own fixed theme tokens apply instead

Why this lives in the Moodle adapter, not ui

Both mechanisms are specifically about adapting to Moodle itself — reading Moodle's own theme configuration, packaging for Moodle's own AMD loading mechanism — rather than a reusable UI mechanism. That is the same criterion used to classify the rest of this adapter's boundary documentation set.

Out of scope here

  • The page-contract/composition mechanism this frontend build serves — lives in middag-io/ui's own decisions record.
  • The product shell and visual-identity instance — lives in the consuming product's own decisions record, not this OSS adapter.

MIDDAG © 2015-2026