Extension Assembly Pipeline
LightningAddon uses a two-stage build: each app is built by Vite, then repo-assemble combines them into a single extension package.
Stage 1: Vite Builds
Each extension context builds independently:
| App | Output | Purpose |
|---|---|---|
apps/background | dist/background.js | Service worker |
apps/popup | dist/popup.html, dist/assets/* | Extension popup |
apps/main | dist/index.html, dist/assets/* | Full-page dashboard |
apps/in-page | dist/content_script.js | Content script injected into pages |
Builds run in parallel via Turborepo. Each app has its own dist/ directory.
Stage 2: Assembly
The repo-assemble CLI (from @repo/tooling) reads apps/extension/extension.config.mjs and:
- Clears
apps/extension/dist/ - Copies artifacts from each app's
dist/into the output directory - Copies assets from
packages/assets - Injects the correct manifest (
manifest.chrome.jsonormanifest.firefox.json) asmanifest.json
Configuration
extension.config.mjs defines:
- manifests — Which manifest file to use per build env (
chrome,firefox) - artifacts — Which files to copy and where (e.g.
popup.html,background.js,content_script.js) - assetsDir — Icons and static files
- assetExcludes — Files to skip when copying assets
Build Commands
pnpm build:chrome # BUILD_ENV=chrome → uses manifest.chrome.json
pnpm build:firefox # BUILD_ENV=firefox → uses manifest.firefox.json
Both produce output in apps/extension/dist/. Load that directory as an unpacked extension in Chrome or Firefox.
Adding a Store-Specific Build
To target a specific store (e.g. Edge with its own listing):
- Add
manifest.edge.jsontoapps/extension/manifests/ - Register it in
extension.config.mjs:manifests: {
chrome: 'manifest.chrome.json',
firefox: 'manifest.firefox.json',
edge: 'manifest.edge.json',
}, - Run
BUILD_ENV=edge pnpm build(or addbuild:edgescript)
No source code changes needed—only the manifest differs.
Artifact Dependencies
The assemble step requires that dependent packages have already built. Turborepo's ^build graph ensures @repo/background, @repo/popup, etc. are built before assemble runs.