How to scaffold, compile, and ship a distributable package that extends Lunar’s admin panel at runtime.
An add-on for the panel is a normal Composer package with a Laravel service provider, plus a small npm package that compiles to a single JavaScript bundle. Nothing about it requires recompiling the panel itself — the panel loads the add-on’s bundle at runtime and calls back into it.lunarphp/panel-addon-example is the reference implementation everything on this page is drawn from: fork it with composer create-project lunarphp/panel-addon-example my-addon and replace the example page, slot, and table column with the add-on’s own. tests/panel/Feature/ExampleAddonTest.php in the monorepo exercises this package’s real, unmodified source against the panel’s real Customers routes, so every snippet below is proven to integrate, not just to work in isolation.
Scaffolding the package
This package’s own composer.json looks like this:
{ "name": "lunarphp/panel-addon-example", "description": "Starter template and reference add-on for lunarphp/panel: a page, a nav item, a slot, and a table extension registered at runtime without recompiling the panel. Fork it with `composer create-project lunarphp/panel-addon-example`.", "license": "MIT", "type": "project", "autoload": { "psr-4": { "LunarPanelExample\\": "src/" } }, "require": { "php": "^8.4", "lunarphp/panel": "self.version" }, "extra": { "laravel": { "providers": [ "LunarPanelExample\\ExampleAddonServiceProvider" ] } }}
The extra.laravel.providers entry lets Laravel’s package auto-discovery register the provider without the host app touching config/app.php. The provider itself (src/ExampleAddonServiceProvider.php) registers a Section with the panel, and a Vite module for the compiled bundle:
use Illuminate\Support\ServiceProvider;use Lunar\Panel\Facades\Panel;use Lunar\Panel\PanelManager;class ExampleAddonServiceProvider extends ServiceProvider{ public function boot(): void { Panel::section(new ExampleSection); $this->app->make(PanelManager::class)->vite('example-addon', [ 'input' => 'resources/js/addon.ts', 'hotFile' => null, 'buildDirectory' => 'vendor/lunar-panel/example-addon', // Lets `php artisan lunar:panel:link` symlink this package's // compiled build/ into public/vendor/lunar-panel/example-addon. '__buildSourcePath' => dirname(__DIR__).'/build', ]); }}
PanelManager::vite() is what makes the panel’s Blade entry emit a <script> tag for the add-on’s compiled bundle automatically — no panel changes required for a new add-on to ship its own JS. See Extending the Admin Panel for what a Section can register beyond the page and Vite module shown here.
The npm setup
Two packages are published to npm with each tagged Lunar release, and an add-on depends on them by version, never a file: path:
@lunarphp/panel — the panel’s layout and page components (PageHeader, DataTable, form inputs, overlays, and so on), plus their types.
@lunarphp/panel-vite-plugin — the build preset that compiles an add-on to a single IIFE bundle sharing the panel’s own Vue instance instead of bundling a second copy.
import { defineConfig } from 'vite';import vue from '@vitejs/plugin-vue';import lunarPanelPlugin from '@lunarphp/panel-vite-plugin';// Compiles resources/js/addon.ts to a single IIFE bundle that shares the// panel's Vue instance (window.Vue) instead of bundling its own copy.export default defineConfig({ plugins: [ vue(), lunarPanelPlugin({ name: 'LunarPanelExampleAddon' }), ], build: { outDir: 'build', rollupOptions: { input: 'resources/js/addon.ts', }, },});
@lunarphp/panel-vite-plugin forces output.format: 'iife' and externalizes vue (to the window.Vue global), @inertiajs/vue3 (to window.InertiaVue3), and @lunarphp/panel (to window.LunarPanelUI) — each published by the panel’s own frontend entry at startup. That is what lets the add-on’s bundle call into the panel’s Vue and Inertia runtimes and reuse its layout and page components instead of shipping second copies.
The add-on entry point
resources/js/addon.ts registers the add-on’s pages and slot components:
import WidgetsIndexPage from './pages/Widgets/Index.vue';import InfoBannerComponent from './components/InfoBanner.vue';import LoyaltyCardComponent from './components/LoyaltyCard.vue';// Register eagerly. The panel's frontend entry publishes window.LunarPanel and// is emitted before any add-on script, so it is always present here.window.LunarPanel.registerPages({ 'example-addon::Widgets/Index': WidgetsIndexPage,});window.LunarPanel.registerComponents('example-addon', { InfoBanner: InfoBannerComponent, LoyaltyCard: LoyaltyCardComponent,});
Pages are named {key}::Path/Name, matching the folder structure under resources/js/pages/ and the Inertia component name the add-on’s routes render — see Pages and navigation for how the two sides line up.
Register pages, components, layouts, and translations at the top level of the bundle — never inside window.LunarPanel.booting(). booting() callbacks run after the panel has mounted, which is too late: a page or slot component registered there is missing when Inertia resolves and first renders it on a hard load, and because registration is not reactive the slot never recovers. The panel holds its initial mount until DOMContentLoaded, by which point every add-on script has already run, so anything registered at the top level of a bundle is guaranteed to be in place in time. Reserve booting() for work that genuinely needs the mounted app.
Beyond registerPages(), registerComponents(), and booting(), the runtime exposes registerLayout(name, component) (a persistent layout an add-on page can opt into), registerTranslations(locale, namespace, messages) (push vue-i18n messages directly at runtime), and resolveExtensionComponent(name) (look up a namespaced component registered by any bundle). The typed contract for all of this is the LunarPanelRuntime interface, shipped as dist/runtime.d.ts in the @lunarphp/panel package.
Compiling the bundle
npm installnpm run build
This produces a compiled IIFE plus a manifest in build/. Commit this directory — the host app’s public/ never runs a JS build step for the panel or its add-ons, so the compiled build/ is what gets published or symlinked into place.
Shipping the compiled assets
The __buildSourcePath passed to PanelManager::vite() in the service provider is what lets the panel manage the add-on’s assets without any panel-side configuration:
Production: php artisan vendor:publish --tag=example-addon-panel-assets --force copies the add-on’s build/ into public/vendor/lunar-panel/example-addon/. The panel registers a {key}-panel-assets publish tag for every module’s __buildSourcePath automatically; --tag=panel-all-assets publishes the panel’s own build plus every add-on in one pass.
Local development: php artisan lunar:panel:link symlinks the build/ directory instead, so a rebuild is picked up without re-publishing.
The panel’s Blade entry loops every registered Vite module and emits a <script>/<link> tag for each automatically — no panel changes are required for a new add-on to appear.
Installing the example add-on
composer require lunarphp/panel-addon-example to install it as-is, or composer create-project lunarphp/panel-addon-example my-addon to fork it as the starting point for a new add-on.
Register the provider — auto-discovered via composer.json’s extra.laravel.providers, or added manually.
npm install inside the package, then npm run build.
Publish or symlink the compiled build as described above.
Troubleshooting
A registered page, slot, or column that doesn’t appear is almost always one of:
A slot never renders because its zone prefix doesn’t match the target page’s actual route name (with the panel. prefix stripped) — not a name guessed from what the page conceptually does.
A page component is “not found” client-side because the Inertia::render() name in the route doesn’t exactly match the key passed to window.LunarPanel.registerPages(), including the namespace:: prefix.
Registration never runs because it happened inside booting() instead of at the bundle’s top level.
See Troubleshooting for the full list, including the table-extension and settings-layout gotchas.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Lunar PHP","colors":{"primary":"#4bc7f8","light":"#4bc7f8","dark":"#4bc7f8"},"logo":{"light":"https://mintcdn.com/lunar-b8371d04/ZhguENt7LP0pq4Z_/logo/lunar-logo.svg?fit=max\u0026auto=format\u0026n=ZhguENt7LP0pq4Z_\u0026q=85\u0026s=c996daa3fdcce9daab23698d2d23a13a","dark":"https://mintcdn.com/lunar-b8371d04/ZhguENt7LP0pq4Z_/logo/lunar-logo-dark.svg?fit=max\u0026auto=format\u0026n=ZhguENt7LP0pq4Z_\u0026q=85\u0026s=3aadec4ff031bb880a6d89aa430993e4"},"favicon":"https://mintcdn.com/lunar-b8371d04/ZhguENt7LP0pq4Z_/favicon.svg?fit=max\u0026auto=format\u0026n=ZhguENt7LP0pq4Z_\u0026q=85\u0026s=62ef311645899e2e1404b36fcb216788","appearance":{"default":"dark"},"background":{"decoration":"grid"},"navbar":{"primary":{"type":"github","href":"https://github.com/lunarphp/lunar"}},"footer":{"socials":{"website":"https://lunarphp.com","x":"https://x.com/lunarphp","github":"https://github.com/lunarphp","discord":"https://lunarphp.com/discord","linkedin":"https://linkedin.com/company/lunarphp"}},"fonts":{"heading":{"family":"Poppins"}},"integrations":{"fathom":{"siteId":"KMZGQTYE"}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"lunar-b8371d04","hasAudioNarration":false,"actualSubdomain":"lunar-b8371d04","customDomains":["docs.lunarphp.com"],"gitSource":{"type":"github","owner":"lunarphp","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":false,"edits":false,"issues":false},"entitlements":{},"buildId":"6b043d737a57ff01f3eba3f5","clientVersion":"0.0.4377","searchFilterCounts":[{"language":"default","tag":"Reference","count":94},{"language":"default","tag":"Core","count":78},{"language":"default","tag":"Extending","count":49},{"language":"default","tag":"Admin Panel","count":31},{"language":"default","tag":"Getting Started","count":29},{"language":"default","tag":"Guides","count":20},{"language":"default","tag":"Order Management","count":18},{"language":"default","tag":"Storefront","count":17},{"language":"default","tag":"Overview","count":16},{"language":"default","tag":"Catalog","count":15}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":true},"customCss":[{"filePath":"style.css","content":".btn{background-color:hsl(197, 93%, 63%);color:white;padding:5px 20px;border-radius:7px}.btn:hover{background-color:hsl(197, 93%, 53%)}"}]}
{"page":{"pagePath":"2.x/admin/extending/addons","slug":"/2.x/admin/extending/addons","pageMetadata":{"title":"Building an Add-on","sidebarTitle":"Add-ons","description":"How to scaffold, compile, and ship a distributable package that extends Lunar's admin panel at runtime.","href":"/2.x/admin/extending/addons"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"How to scaffold, compile, and ship a distributable package that extends Lunar’s admin panel at runtime.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`An add-on for the panel is a normal Composer package with a Laravel service provider, plus a small npm package that compiles to a single JavaScript bundle. Nothing about it requires recompiling the panel itself — the panel loads the add-on’s bundle at runtime and calls back into it.`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`lunarphp/panel-addon-example`}),` is the reference implementation everything on this page is drawn from: fork it with `,_jsx(_components.code,{children:`composer create-project lunarphp/panel-addon-example my-addon`}),` and replace the example page, slot, and table column with the add-on’s own. `,_jsx(_components.code,{children:`tests/panel/Feature/ExampleAddonTest.php`}),` in the monorepo exercises this package’s real, unmodified source against the panel’s real Customers routes, so every snippet below is proven to integrate, not just to work in isolation.`]}),`\n`,_jsx(Heading,{level:`2`,id:`scaffolding-the-package`,children:`Scaffolding the package`}),`\n`,_jsxs(_components.p,{children:[`This package’s own `,_jsx(_components.code,{children:`composer.json`}),` looks like this:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`22`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`22`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"lunarphp/panel-addon-example\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"description\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:'\"Starter template and reference add-on for lunarphp/panel: a page, a nav item, a slot, and a table extension registered at runtime without recompiling the panel. Fork it with `composer create-project lunarphp/panel-addon-example`.\"'}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"license\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"MIT\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"project\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"autoload\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"psr-4\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"LunarPanelExample`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\\\\`}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"src/\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"require\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"php\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"^8.4\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"lunarphp/panel\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"self.version\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"extra\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"laravel\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"providers\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"LunarPanelExample`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\\\\`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`ExampleAddonServiceProvider\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`extra.laravel.providers`}),` entry lets Laravel’s package auto-discovery register the provider without the host app touching `,_jsx(_components.code,{children:`config/app.php`}),`. The provider itself (`,_jsx(_components.code,{children:`src/ExampleAddonServiceProvider.php`}),`) registers a `,_jsx(_components.code,{children:`Section`}),` with the panel, and a Vite module for the compiled bundle:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`20`,language:`php`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`php`,children:_jsxs(_components.code,{language:`php`,numberOfLines:`20`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`use`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` Illuminate\\\\Support\\\\`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`ServiceProvider`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`use`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` Lunar\\\\Panel\\\\Facades\\\\`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`Panel`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`use`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` Lunar\\\\Panel\\\\`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`PanelManager`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`class`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` ExampleAddonServiceProvider`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` extends`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` ServiceProvider`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` public`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` function`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` boot`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` void`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` Panel`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`section`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`new`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:` ExampleSection`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` $this`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`app`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`make`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`PanelManager`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`class`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`vite`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'example-addon'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'input'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =>`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'resources/js/addon.ts'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'hotFile'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =>`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` null`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'buildDirectory'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =>`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'vendor/lunar-panel/example-addon'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:\" // Lets `php artisan lunar:panel:link` symlink this package's\"})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // compiled build/ into public/vendor/lunar-panel/example-addon.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '__buildSourcePath'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =>`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:` dirname`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`__DIR__`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'/build'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]);`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`PanelManager::vite()`}),` is what makes the panel’s Blade entry emit a `,_jsx(_components.code,{children:`\u003cscript>`}),` tag for the add-on’s compiled bundle automatically — no panel changes required for a new add-on to ship its own JS. See `,_jsx(_components.a,{href:`/2.x/admin/extending/overview`,children:`Extending the Admin Panel`}),` for what a `,_jsx(_components.code,{children:`Section`}),` can register beyond the page and Vite module shown here.`]}),`\n`,_jsx(Heading,{level:`2`,id:`the-npm-setup`,children:`The npm setup`}),`\n`,_jsxs(_components.p,{children:[`Two packages are published to npm with each tagged Lunar release, and an add-on depends on them `,_jsx(_components.strong,{children:`by version`}),`, never a `,_jsx(_components.code,{children:`file:`}),` path:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`@lunarphp/panel`}),` — the panel’s layout and page components (`,_jsx(_components.code,{children:`PageHeader`}),`, `,_jsx(_components.code,{children:`DataTable`}),`, form inputs, overlays, and so on), plus their types.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`@lunarphp/panel-vite-plugin`}),` — the build preset that compiles an add-on to a single IIFE bundle sharing the panel’s own Vue instance instead of bundling a second copy.`]}),`\n`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`17`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`17`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"@lunarphp/panel-addon-example\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"private\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"module\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"scripts\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"build\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"vite build\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"dev\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"vite\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"devDependencies\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"@inertiajs/vue3\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"^2.0.0\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"@lunarphp/panel\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"^0.2.0\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"@lunarphp/panel-vite-plugin\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"^0.1.0\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"@vitejs/plugin-vue\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"^5.2.0\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"vite\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"^6.0.0\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"vue\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"^3.5.13\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`vite-config-js`,children:_jsx(_components.code,{children:`vite.config.js`})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`18`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`18`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`defineConfig`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'vite'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` vue`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '@vitejs/plugin-vue'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` lunarPanelPlugin`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '@lunarphp/panel-vite-plugin'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Compiles resources/js/addon.ts to a single IIFE bundle that shares the`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// panel's Vue instance (window.Vue) instead of bundling its own copy.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`export`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` default`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` defineConfig`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` plugins:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` vue`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` lunarPanelPlugin`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`name:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'LunarPanelExampleAddon'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` build:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` outDir:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'build'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` rollupOptions:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` input:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'resources/js/addon.ts'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#D4D4D4`},children:`})`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`@lunarphp/panel-vite-plugin`}),` forces `,_jsx(_components.code,{children:`output.format: 'iife'`}),` and externalizes `,_jsx(_components.code,{children:`vue`}),` (to the `,_jsx(_components.code,{children:`window.Vue`}),` global), `,_jsx(_components.code,{children:`@inertiajs/vue3`}),` (to `,_jsx(_components.code,{children:`window.InertiaVue3`}),`), and `,_jsx(_components.code,{children:`@lunarphp/panel`}),` (to `,_jsx(_components.code,{children:`window.LunarPanelUI`}),`) — each published by the panel’s own frontend entry at startup. That is what lets the add-on’s bundle call into the panel’s Vue and Inertia runtimes and reuse its layout and page components instead of shipping second copies.`]}),`\n`,_jsx(Heading,{level:`2`,id:`the-add-on-entry-point`,children:`The add-on entry point`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`resources/js/addon.ts`}),` registers the add-on’s pages and slot components:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`14`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`14`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` WidgetsIndexPage`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` './pages/Widgets/Index.vue'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` InfoBannerComponent`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` './components/InfoBanner.vue'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` LoyaltyCardComponent`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` './components/LoyaltyCard.vue'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Register eagerly. The panel's frontend entry publishes window.LunarPanel and`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// is emitted before any add-on script, so it is always present here.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`LunarPanel`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`registerPages`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'example-addon::Widgets/Index'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` WidgetsIndexPage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`window`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`LunarPanel`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`registerComponents`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'example-addon'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` InfoBanner:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` InfoBannerComponent`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` LoyaltyCard:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` LoyaltyCardComponent`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Pages are named `,_jsx(_components.code,{children:`{key}::Path/Name`}),`, matching the folder structure under `,_jsx(_components.code,{children:`resources/js/pages/`}),` and the Inertia component name the add-on’s routes render — see `,_jsx(_components.a,{href:`/2.x/admin/extending/pages`,children:`Pages and navigation`}),` for how the two sides line up.`]}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`Register pages, components, layouts, and translations at the `,_jsx(_components.strong,{children:`top level`}),` of the bundle — never inside `,_jsx(_components.code,{children:`window.LunarPanel.booting()`}),`. `,_jsx(_components.code,{children:`booting()`}),` callbacks run after the panel has mounted, which is too late: a page or slot component registered there is missing when Inertia resolves and first renders it on a hard load, and because registration is not reactive the slot never recovers. The panel holds its initial mount until `,_jsx(_components.code,{children:`DOMContentLoaded`}),`, by which point every add-on script has already run, so anything registered at the top level of a bundle is guaranteed to be in place in time. Reserve `,_jsx(_components.code,{children:`booting()`}),` for work that genuinely needs the mounted app.`]})}),`\n`,_jsxs(_components.p,{children:[`Beyond `,_jsx(_components.code,{children:`registerPages()`}),`, `,_jsx(_components.code,{children:`registerComponents()`}),`, and `,_jsx(_components.code,{children:`booting()`}),`, the runtime exposes `,_jsx(_components.code,{children:`registerLayout(name, component)`}),` (a persistent layout an add-on page can opt into), `,_jsx(_components.code,{children:`registerTranslations(locale, namespace, messages)`}),` (push vue-i18n messages directly at runtime), and `,_jsx(_components.code,{children:`resolveExtensionComponent(name)`}),` (look up a namespaced component registered by any bundle). The typed contract for all of this is the `,_jsx(_components.code,{children:`LunarPanelRuntime`}),` interface, shipped as `,_jsx(_components.code,{children:`dist/runtime.d.ts`}),` in the `,_jsx(_components.code,{children:`@lunarphp/panel`}),` package.`]}),`\n`,_jsx(Heading,{level:`2`,id:`compiling-the-bundle`,children:`Compiling the bundle`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`npm`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` run`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` build`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`This produces a compiled IIFE plus a manifest in `,_jsx(_components.code,{children:`build/`}),`. Commit this directory — the host app’s `,_jsx(_components.code,{children:`public/`}),` never runs a JS build step for the panel or its add-ons, so the compiled `,_jsx(_components.code,{children:`build/`}),` is what gets published or symlinked into place.`]}),`\n`,_jsx(Heading,{level:`2`,id:`shipping-the-compiled-assets`,children:`Shipping the compiled assets`}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`__buildSourcePath`}),` passed to `,_jsx(_components.code,{children:`PanelManager::vite()`}),` in the service provider is what lets the panel manage the add-on’s assets without any panel-side configuration:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Production`}),`: `,_jsx(_components.code,{children:`php artisan vendor:publish --tag=example-addon-panel-assets --force`}),` copies the add-on’s `,_jsx(_components.code,{children:`build/`}),` into `,_jsx(_components.code,{children:`public/vendor/lunar-panel/example-addon/`}),`. The panel registers a `,_jsx(_components.code,{children:`{key}-panel-assets`}),` publish tag for every module’s `,_jsx(_components.code,{children:`__buildSourcePath`}),` automatically; `,_jsx(_components.code,{children:`--tag=panel-all-assets`}),` publishes the panel’s own build plus every add-on in one pass.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Local development`}),`: `,_jsx(_components.code,{children:`php artisan lunar:panel:link`}),` symlinks the `,_jsx(_components.code,{children:`build/`}),` directory instead, so a rebuild is picked up without re-publishing.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`The panel’s Blade entry loops every registered Vite module and emits a `,_jsx(_components.code,{children:`\u003cscript>`}),`/`,_jsx(_components.code,{children:`\u003clink>`}),` tag for each automatically — no panel changes are required for a new add-on to appear.`]}),`\n`,_jsx(Heading,{level:`2`,id:`installing-the-example-add-on`,children:`Installing the example add-on`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`composer require lunarphp/panel-addon-example`}),` to install it as-is, or `,_jsx(_components.code,{children:`composer create-project lunarphp/panel-addon-example my-addon`}),` to fork it as the starting point for a new add-on.`]}),`\n`,_jsxs(_components.li,{children:[`Register the provider — auto-discovered via `,_jsx(_components.code,{children:`composer.json`}),`’s `,_jsx(_components.code,{children:`extra.laravel.providers`}),`, or added manually.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`npm install`}),` inside the package, then `,_jsx(_components.code,{children:`npm run build`}),`.`]}),`\n`,_jsx(_components.li,{children:`Publish or symlink the compiled build as described above.`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`troubleshooting`,children:`Troubleshooting`}),`\n`,_jsx(_components.p,{children:`A registered page, slot, or column that doesn’t appear is almost always one of:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`A slot never renders`}),` because its zone prefix doesn’t match the target page’s actual route name (with the `,_jsx(_components.code,{children:`panel.`}),` prefix stripped) — not a name guessed from what the page conceptually does.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`A page component is “not found”`}),` client-side because the `,_jsx(_components.code,{children:`Inertia::render()`}),` name in the route doesn’t exactly match the key passed to `,_jsx(_components.code,{children:`window.LunarPanel.registerPages()`}),`, including the `,_jsx(_components.code,{children:`namespace::`}),` prefix.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Registration never runs`}),` because it happened inside `,_jsx(_components.code,{children:`booting()`}),` instead of at the bundle’s top level.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[`See `,_jsx(_components.a,{href:`/2.x/admin/extending/troubleshooting`,children:`Troubleshooting`}),` for the full list, including the table-extension and settings-layout gotchas.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Building an Add-on","sidebarTitle":"Add-ons","description":"How to scaffold, compile, and ship a distributable package that extends Lunar's admin panel at runtime.","href":"/2.x/admin/extending/addons"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Scaffolding the package","slug":"scaffolding-the-package","depth":2,"children":[]},{"title":"The npm setup","slug":"the-npm-setup","depth":2,"children":[{"title":"vite.config.js","slug":"vite-config-js","depth":3,"children":[]}]},{"title":"The add-on entry point","slug":"the-add-on-entry-point","depth":2,"children":[]},{"title":"Compiling the bundle","slug":"compiling-the-bundle","depth":2,"children":[]},{"title":"Shipping the compiled assets","slug":"shipping-the-compiled-assets","depth":2,"children":[]},{"title":"Installing the example add-on","slug":"installing-the-example-add-on","depth":2,"children":[]},{"title":"Troubleshooting","slug":"troubleshooting","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/lunar-b8371d04/43e98106a0b337d4/tally-embed.js"],"subdomain":"lunar-b8371d04","siteName":"Lunar PHP","title":"Building an Add-on - Lunar PHP","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{"v1.x":{"href":"/1.x/admin/extending/addons","matchLevel":1},"v2.x (alpha)":{"href":"/2.x/admin/extending/addons","matchLevel":0},"v0.x":{"href":"/0.x/extending/carts","matchLevel":2}},"firstHrefInLanguage":{}},"lastModified":"2026-11-11T17:12:26.836Z","originalFileLocation":"2.x/admin/extending/addons.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"dark\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"How to scaffold, compile, and ship a distributable package that extends Lunar\u0026#x27;s admin panel at runtime.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Lunar PHP\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/lunar-b8371d04/VkxpWOT1bm2GLFiZ/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/lunar-b8371d04/VkxpWOT1bm2GLFiZ/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/lunar-b8371d04/VkxpWOT1bm2GLFiZ/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/lunar-b8371d04/VkxpWOT1bm2GLFiZ/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/lunar-b8371d04/VkxpWOT1bm2GLFiZ/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/lunar-b8371d04/VkxpWOT1bm2GLFiZ/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/lunar-b8371d04/VkxpWOT1bm2GLFiZ/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/lunar-b8371d04/VkxpWOT1bm2GLFiZ/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/lunar-b8371d04/VkxpWOT1bm2GLFiZ/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Building an Add-on - Lunar PHP\">\u003cmeta data-mint-head property=\"og:description\" content=\"How to scaffold, compile, and ship a distributable package that extends Lunar\u0026#x27;s admin panel at runtime.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Lunar PHP\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.lunarphp.com/2.x/admin/extending/addons\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://lunar-b8371d04.mintlify.site/_mintlify/api/og/v2?division=Extending\u0026amp;title=Building+an+Add-on\u0026amp;description=How+to+scaffold%2C+compile%2C+and+ship+a+distributable+package+that+extends+Lunar%27s+admin+panel+at+runtime.\u0026amp;theme=cf06fc1a48ca28450a5a669d\u0026amp;signature=7d9d6bd909b47c5c9841f8708bb51dd8c7b8768530ba2a211b91b6738892dd81\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Building an Add-on - Lunar PHP\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"How to scaffold, compile, and ship a distributable package that extends Lunar\u0026#x27;s admin panel at runtime.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://lunar-b8371d04.mintlify.site/_mintlify/api/og/v2?division=Extending\u0026amp;title=Building+an+Add-on\u0026amp;description=How+to+scaffold%2C+compile%2C+and+ship+a+distributable+package+that+extends+Lunar%27s+admin+panel+at+runtime.\u0026amp;theme=cf06fc1a48ca28450a5a669d\u0026amp;signature=7d9d6bd909b47c5c9841f8708bb51dd8c7b8768530ba2a211b91b6738892dd81\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/lunar-b8371d04/VkxpWOT1bm2GLFiZ/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Lunar PHP\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#4bc7f8\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.lunarphp.com/2.x/admin/extending/addons\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/2.x/admin/extending/addons.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.lunarphp.com/#organization\",\"name\":\"Lunar PHP\",\"url\":\"https://docs.lunarphp.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/lunar-b8371d04/ZhguENt7LP0pq4Z_/logo/lunar-logo.svg?fit=max\u0026auto=format\u0026n=ZhguENt7LP0pq4Z_\u0026q=85\u0026s=c996daa3fdcce9daab23698d2d23a13a\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.lunarphp.com#website\",\"name\":\"Lunar PHP\",\"url\":\"https://docs.lunarphp.com\",\"publisher\":{\"@id\":\"https://docs.lunarphp.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.lunarphp.com/2.x/admin/extending/addons#webpage\",\"url\":\"https://docs.lunarphp.com/2.x/admin/extending/addons\",\"name\":\"Building an Add-on\",\"description\":\"How to scaffold, compile, and ship a distributable package that extends Lunar's admin panel at runtime.\",\"dateModified\":\"2026-11-11T17:12:26.836Z\",\"isPartOf\":{\"@id\":\"https://docs.lunarphp.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.lunarphp.com/2.x/admin/extending/addons#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.lunarphp.com/2.x/admin/extending/addons#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Extending\",\"item\":\"https://docs.lunarphp.com/2.x/admin/extending/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Building an Add-on\",\"item\":\"https://docs.lunarphp.com/2.x/admin/extending/addons\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.lunarphp.com/2.x/admin/extending/addons#article\",\"headline\":\"Building an Add-on\",\"name\":\"Building an Add-on\",\"description\":\"How to scaffold, compile, and ship a distributable package that extends Lunar's admin panel at runtime.\",\"url\":\"https://docs.lunarphp.com/2.x/admin/extending/addons\",\"mainEntityOfPage\":{\"@id\":\"https://docs.lunarphp.com/2.x/admin/extending/addons#webpage\"},\"dateModified\":\"2026-11-11T17:12:26.836Z\",\"publisher\":{\"@id\":\"https://docs.lunarphp.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.lunarphp.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Lunar PHP\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Lunar PHP\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/2.x/admin/extending/addons.md","siteName":"Lunar PHP","nav":{"global":null,"versions":[{"version":"v1.x","pages":[{"title":"v1.x","href":"/1.x/admin/extending/addons"}]},{"version":"v2.x (alpha)","tabs":[{"tab":"Getting Started","pages":[{"title":"Getting Started","href":"/2.x/getting-started/overview/introduction"}]},{"tab":"Guides","pages":[{"title":"Guides","href":"/2.x/guides/catalog-menu"}]},{"tab":"Reference","pages":[{"title":"Reference","href":"/2.x/reference/associations"}]},{"tab":"Admin Panel","groups":[{"group":"Getting Started","pages":[{"title":"Introduction","href":"/2.x/admin/introduction"},{"title":"Installation","href":"/2.x/admin/installation"},{"title":"Configuration","href":"/2.x/admin/configuration"},{"title":"Access Control","href":"/2.x/admin/access-control"}]},{"group":"Add-on sections","pages":[{"title":"Bundles","href":"/2.x/admin/bundles"}]},{"group":"Extending","pages":[{"title":"Extending the Admin Panel","description":"The concepts behind extending Lunar's admin panel: sections, hooks, and the registries a service provider can call directly.","href":"/2.x/admin/extending/overview"},{"title":"Building an Add-on","sidebarTitle":"Add-ons","href":"/2.x/admin/extending/addons"},{"title":"Pages and Navigation","sidebarTitle":"Pages","description":"Registering routes and Inertia pages for the admin panel, and adding them to the sidebar and Settings navigation.","href":"/2.x/admin/extending/pages"},{"title":"Slots","sidebarTitle":"Slots","href":"/2.x/admin/extending/slots"},{"title":"Extending Tables","sidebarTitle":"Tables","href":"/2.x/admin/extending/tables"},{"title":"Page Actions","sidebarTitle":"Page Actions","href":"/2.x/admin/extending/page-actions"},{"title":"Dashboard Widgets","sidebarTitle":"Widgets","href":"/2.x/admin/extending/widgets"},{"title":"Global Search","sidebarTitle":"Search","href":"/2.x/admin/extending/search"},{"title":"Edit Drafts","sidebarTitle":"Edit Drafts","href":"/2.x/admin/extending/edit-drafts"},{"title":"Form Slices","sidebarTitle":"Form Slices","href":"/2.x/admin/extending/form-slices"},{"title":"Discount Type Forms","sidebarTitle":"Discount Forms","href":"/2.x/admin/extending/discount-forms"},{"title":"Ordering with Position","sidebarTitle":"Ordering","href":"/2.x/admin/extending/ordering"},{"title":"Translating an Add-on","sidebarTitle":"Translations","href":"/2.x/admin/extending/translations"},{"title":"Testing an Add-on","sidebarTitle":"Testing","href":"/2.x/admin/extending/testing"},{"title":"Troubleshooting Add-ons","sidebarTitle":"Troubleshooting","href":"/2.x/admin/extending/troubleshooting"}]}]},{"tab":"Add-ons","pages":[{"title":"Add-ons","href":"/2.x/addons/filament/overview"}]},{"tab":"Support","pages":[{"title":"Support","href":"/support/community"}]},{"tab":"Flight Plan","pages":[{"title":"Flight Plan","href":"/logs/flight-plan"}]}]},{"version":"v0.x","pages":[{"title":"v0.x","href":"/0.x/extending/carts"}]}]},"basePath":"","title":"Building an Add-on - Lunar PHP","deploymentId":"dpl_Ab6nteg7kvyK8iL73naC2n7fmsWK","buildId":"dpl_Ab6nteg7kvyK8iL73naC2n7fmsWK","dynamics":[],"chunks":[]}