build
Build the production frontend from the AntelopeJS project itself, without a backend, a network or a secret.
ajs dms build builds the production frontend of an AntelopeJS project. That is the client bundle, its compressed copies, the server-rendering bundle, the e-mail bundle and the bundle of the modules' server routes. It reads the project, not a backend.
$ ajs dms build --help
Usage: ajs dms build [options]
Build the production frontend from the AntelopeJS project itself: its
antelope.config.ts, evaluated for the environment, and the frontend of each
installed module that declares one (dmsFrontend in its package.json). No backend
is asked. The build holds no secret, and start computes the modules' options
again from the deployment's variables.
Options:
--project <dir> The AntelopeJS project whose antelope.config.ts and
installed modules make the frontend (default: ".")
-e, --env <environment> The AntelopeJS environment whose configuration
applies, as ajs project start -e (default:
"production", env: ANTELOPEJS_LAUNCH_ENV)
--workspace <dir> Build into this directory instead of
<project>/.dms-frontend (env: DMS_WORKSPACE_DIR)
-f, --force Reinstall the workspace dependencies
--setup-only Set the workspace up and install its dependencies,
then stop before the bundles
--no-install With --setup-only, write the workspace without
installing its dependencies
--prepared Build the workspace --setup-only set up, as it is,
without setting it up again; exit 3 when it is not
prepared
-h, --help Show help for a command
What the build reads
The backend and the frontend are built from the same repository, so the frontend computes everything itself. It reads three things.
- The modules and their configuration. AntelopeJS's own config loader evaluates
antelope.config.tswith the rulesajs project start -e <env>applies. Those rules cover the environment's section, the modules' JSON files andenvOverrides. A${@<module>.<VAR>}reference resolves with the function its provider declares asantelopeJs.configVarsFilein itspackage.json. That function is the pureconfigVars(config)the provider's ownprovidepublishes from, and the build calls it with the provider's configuration. For example,${@api.API_PUBLIC_BASE_URL}is the api module'spublicBaseUrl, or its local origin whenpublicBaseUrlis unset. A provider that is not installed, or that declares no such file, leaves its references unresolved. - Each module's frontend. The build reads the module's installed package,
node_modules/<package>, or AntelopeJS's module cache, or the local source path. In it, it reads the file the package names asdmsFrontendin itspackage.json. That file exportsfrontendModule(config, { dev }), the same pure function the module's backend passes toAddFrontendModule. It returns the frontend source directory, its options and the backend routes it declares. - The modules' versions. Each package gives its version, locked by the project's lockfile.
Nothing goes over the network except the workspace's own pnpm install. The build leaves out, with a warning, a module whose package ships frontend-vue/ without a dmsFrontend declaration. It also leaves out a configured module that is not installed. Run ajs project build first to install it.
The build keeps no secret. It writes private options with every value emptied, and it reads neither DMS_SESSION_SECRET nor the backend's secrets. start reads them from its environment, and computes the public options again from the deployment's variables.
A build
$ ajs dms build
ajs dms build . · production
✔ Workspace generated 2.1s
✔ Installed 812 packages 41.0s
ℹ Building for production
Workspace ./.dms-frontend
✔ Built the client bundle 1m 38s
✔ Compressed the client assets 32.2s
✔ Built the SSR bundle 1m 35s
✔ Built the e-mail bundle 3.6s
✔ Built the server modules 2.8s
▲ 1 Vite warning
→ Run with --verbose to list them
Built the production frontend → ./.dms-frontend/dist · 4m 41s
Next steps
ajs dms start -b <backend> from the project, with DMS_SESSION_SECRET, the server's secrets and the deployment's variables in its environment
The steps write into the workspace's dist/ directory:
| Step | Output |
|---|---|
| Client bundle | dist/client, the browser application |
| Compressed assets | Pre-compressed copies of the client assets, which the server sends to browsers that accept them |
| SSR bundle | dist/ssr, the server renderer |
| E-mail bundle | dist/server, the e-mail renderer and its translation catalogs under dist/server/locales/ |
| Server modules | dist/server-modules, the modules' dms.server.ts and what they import |
A step that fails stops the build, prints the error Vite reported, or the last lines of the step's output, and points at the file in the module rather than its copy in the workspace. --verbose streams every line of every step.
Other users can read the workspace's files, since they hold no secret. A container image is often built as one user and served as another.
The client entry
Every page loads the client entry, and what it imports statically, before it runs anything. A module's dms.frontend.ts, its plugins and whatever they import are part of it, so every page of the application pays their weight, the sign-in page included. Once the build succeeds, it reports what the entry weighs and how much of it each frontend module's sources make up. It estimates the shares from the bundle's own metadata, at no build cost:
ℹ Client entry 349 KB Brotli (1.4 MB), loaded first by every page
shared 263 KB (1 MB)
@antelopejs/dms-frontend-vue 43 KB (175 KB)
@acme/reports-frontend-vue 61 KB (250 KB)
…
▲ @acme/reports-frontend-vue adds 61 KB Brotli to the client entry
What a module's dms.frontend.ts and its plugins import is loaded by every page: render a component they only show on some pages by its registered name or with defineAsyncComponent
The threshold is 50 KB (DMS_ENTRY_WEIGHT_WARNING, in KB; 0 turns the warning off)
shared is what no single module owns. It holds the renderer's runtime, Vue, the UI and icon libraries and the bundler's own code. translations is the merged translation catalog, and it appears only when a module imports it statically. Otherwise the application loads each language's catalog on demand, from a file of its own. The report therefore leaves out the catalog the server preloads next to the entry for the page's language, although a signed-in user's page downloads it.
The report splits each chunk's bytes among the modules it holds, in proportion to the code the bundler rendered for each before minification. Each module's Brotli size is its share of the entry's. Code shares are within a few percent. Data that minification does not shrink, such as a translation catalog, comes out about a quarter lower than it is.
A module above DMS_ENTRY_WEIGHT_WARNING KB of Brotli gets a warning, and the build still succeeds. The default is 50, a little above the DMS core module's own 43 KB. The usual cause is a plugin that imports a component only some pages show. Render the component the module registers by its name, or wrap it in defineAsyncComponent, and its code loads with the pages that show it.
Setting up and building in two steps
A build first sets its workspace up. It copies the templates and each module's frontend, generates the module registry and installs the dependencies. Then it runs the bundle steps. A tool that caches builds, such as a verification harness, can run the two halves apart. It sets the workspace up once, keys a cache on what the workspace holds, and bundles only on a miss.
--setup-only sets the workspace up, installs its dependencies, and stops before the bundles:
$ ajs dms build --setup-only
ajs dms build . · production
✔ Workspace generated 2.1s
✔ Installed 812 packages 41.0s
Set up the production workspace → ./.dms-frontend · 43.2s
Next steps
ajs dms build --prepared builds this workspace as it is
--no-install with --setup-only writes the workspace and leaves its dependencies as they are. Use it to read what a build would bundle without paying for the install.
--prepared runs the bundle steps on the workspace as the setup left it. It reads neither the project nor the modules' sources again, so a file that changes after the setup does not reach the build. A step that fails still points at the file in the module, because the setup records where each module's sources are.
--prepared refuses a workspace that is not ready, with exit code 3, before it bundles anything. That happens when no setup finished in it, or when its dependencies are not installed or changed since the install. A setup that stops halfway, such as on a failed install, leaves a workspace --prepared refuses. A caller that gets 3 runs a plain ajs dms build instead:
$ ajs dms build --prepared
ajs dms build . · production
✖ ./.dms-frontend is not prepared
No production setup finished in it.
→ Run ajs dms build --setup-only first, or build without --prepared
--prepared takes no --force, and --no-install needs --setup-only. Pass the same --project, -e and --workspace to both runs.
Forcing a clean build
build reinstalls the workspace dependencies only when the modules' dependencies changed. --force reinstalls them. To start from an empty workspace, delete it first.
Next
Serve the build with ajs dms start, or read Production for a complete deployment.