HomeCore Learning Journey › Session 7 — Client libraries & frontend workflow

Session 7 — Client libraries & frontend workflow

Purpose: Ship CSS/JS the AEM way: clientlib categories, dependencies, embedding, and integrating a modern frontend build.

Who this page is for

AudienceWhy it matters to you
Frontend engineersYour bundling story in AEM

ClientLibs = named bundles in the repo

A client library folder (cq:ClientLibraryFolder) declares a category (its bundle name), optional dependencies (loaded before, kept separate) and embeds (inlined into this bundle).

/apps/phi-academy/clientlibs/
  ├── clientlib-base/           categories=[phi.base]   embeds component CSS
  │     ├── css.txt             ← ordered list of CSS sources
  │     └── js.txt
  ├── clientlib-site/           categories=[phi.site]  dependencies=[phi.base]
  └── clientlib-dependencies/   categories=[phi.dependencies]  (vendor)
ClientLib conceptFrontend-world equivalent
categoryNamed webpack entry/bundle
dependenciesExternal chunk loaded first
embedMerged into the bundle (like importing into one entry)
css.txt / js.txtOrdered import manifest
allowProxyExposes /apps libs via /etc.clientlibs to publish safely

Pages include bundles by category in HTL:

<sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html"
     data-sly-call="${clientlib.all @ categories='phi.site'}"></sly>

Modern build integration

The archetype's ui.frontend module is a standard webpack/TS project whose build output is copied into a clientlib by the aem-clientlib-generator. You keep your familiar workflow (npm, TS, Sass, linting); AEM only sees the compiled artefact.

ui.frontend (npm run build) ──▶ dist/ ──clientlib-generator──▶ ui.apps clientlib ──mvn──▶ AEM

Rules of thumb

Quick navigation