App config
How every layer's app config file is merged before the modules set up, in which order, and how dev applies an edit without a reload.
Each layer of a module may hold an app/app.config.ts, and so may the module root when it has no layers/ directory. Its default export is a plain object. It holds branding, the Nuxt UI ui key (colors, icons, component themes), or any value the modules read through useDmsAppConfig().
defineDmsAppConfig is an auto-import of the renderer, available in app.config.ts without an import. The declare line only gives this example the type that the renderer exports:
declare const defineDmsAppConfig: typeof import("@antelopejs/dms-frontend/templates/vue/frontend-module").defineDmsAppConfig;
export default defineDmsAppConfig({
branding: { logo: { light: "/branding/logo.svg" } },
ui: { colors: { primary: "emerald" } },
});
Merge order
The loader merges every file with defu before the first module is set up. Records merge key by key and arrays are concatenated. useDmsAppConfig() already holds the result when a setup runs.
- Modules merge in manifest-priority order, highest first.
- Within a module, layers merge from the last by name to the first. A contested
public/file resolves in the same order.
A project's layer therefore overrides the DMS layer, and the DMS fills in every key the project leaves out. The workspace typecheck reads each file as a partial DmsAppConfig, every key optional at any depth, so a layer sets only the keys it overrides, ui.colors without ui.icons for instance. A setup can still read and extend the config. The Nuxt UI app config is derived from the result, and so is the config that e-mails render with (see E-mails).
The file is TypeScript only. The server renderer and the e-mail bundle import it in Node.js, and the browser imports it too, so it must not touch browser globals when it loads.
In development
ajs dms dev applies an edit at once. The next server render uses it, and the open page updates useDmsAppConfig() and the Nuxt UI app config in place, colors included, without a reload. Changes that the modules' setup made to the config stay on top of the edited values. Adding or removing a config file is applied the same way.
Entries that merge their own config
An entry can also merge its own config into useDmsAppConfig() in its setup. The values stay the same, but the config is then merged twice. Because defu concatenates arrays, every array the config declares holds its entries twice, the Nuxt UI compoundVariants among them. Nuxt UI resolves the repeated classes to the same ones, so nothing changes on screen.
Such an entry imports the config file itself. In ajs dms dev, an edit to that file then reloads the page instead of updating it in place. An entry that leaves the merge to the loader avoids both effects.