entry

entry defines the entry map: keys are entry names, values are JS/TS script paths or structured objects relative to baseDir. When omitted, the framework discovers background, content, popup, options, sidepanel, devtools under appDir (default app/) by directory name.

Type and baseDir

  • Type: Record<string, string | { src: string; html?: boolean | string }> | undefined
  • baseDir: When appDir is not set, baseDir = app/; when set, baseDir = appDir. All entry values are relative to baseDir.

Reserved entry names

These names are fixed by the extension spec and framework:

NameTypeDescription
backgroundScript onlyService worker / background script
contentScript onlyContent script
popupScript + HTMLPopup page
optionsScript + HTMLOptions page
sidepanelScript + HTMLSide panel
devtoolsScript + HTMLDevTools page

Other names can be custom entries (e.g. capture, offscreen) as long as the directory has the corresponding script.

Path rules

  • JS/TS entry only: the real entry is always JS/TS (.js, .jsx, .ts, .tsx). HTML is template only.
  • HTML template rules: if you use an HTML template, do not import CSS or other resources in the HTML. The HTML is not compiled; only the JS/TS entry is compiled.
  • Single main entry: HTML templates must include one <script> tag with data-addfox-entry and a JS/TS src:
    • Example: <script type="module" src="./main.ts" data-addfox-entry></script>
  • background and content are script-only entries (no HTML generated).
  • For popup, options, sidepanel, devtools, HTML is generated by default. If a template exists, it is used as the template.

When entry is omitted

The framework scans baseDir and discovers the reserved names by looking for scripts (e.g. background/index.ts, popup/index.ts, popup.ts). If only an HTML template exists, the framework reads data-addfox-entry to locate the JS/TS entry and auto-generates { src, html }.

Supported layouts

  • Flat files under baseDir: popup.ts, content.ts, background.js, etc.
  • Single-level dirs: popup/index.ts, content/index.ts, background/index.ts.

Nested multi-level entry folders are not supported.

Examples

Default discovery (no entry config)

app
background/index.ts
content/index.ts
popup/index.ts
popup/index.html# optional HTML template
options/index.ts
options/index.html# optional HTML template

No entry needed in config. The framework discovers script entries; if an index.html exists alongside the script, it is used as the HTML template.

HTML template only (data-addfox-entry)

app
popup
index.html# template only
main.ts# real entry
<!-- popup/index.html -->
<script type="module" src="./main.ts" data-addfox-entry></script>

No entry needed. The framework reads data-addfox-entry and auto-declares { src, html }.

Custom entries and overrides

// addfox.config.ts
import { defineConfig } from "addfox";

export default defineConfig({
  appDir: "src",
  entry: {
    background: "background/index.ts",
    content: "content/index.ts",
    popup: "popup/index.ts",
    options: "options/index.ts",
    sidepanel: "sidepanel/index.ts",
    capture: "capture/index.ts",
    offscreen: { src: "offscreen/index.ts", html: true },
    settings: { src: "settings/index.ts", html: "settings/index.html" },
  },
});

When entry is set, only the declared entries are used. You can mix reserved and custom names.