App Directory

Addfox follows a convention-over-configuration design philosophy. Understanding the standard directory structure helps you get started quickly and follow best practices.

Project Root

A typical Addfox project structure looks like this:

my-extension/
├── .addfox/           # Build output and cache (auto-generated)
├── app/                # Application source code (configurable)
├── public/             # Static assets
├── addfox.config.ts       # Addfox configuration file
└── package.json        # Project dependencies

.addfox Directory

.addfox is auto-generated by the framework and contains:

  • extension/ — Default build output directory (can be changed via outDir)
  • cache/ — Build cache for accelerating subsequent builds
Tip

Avoid deleting the cache directory unless necessary, as it affects build speed and browser user data reuse.

app Directory

app/ is the default application source directory, containing all extension entries and manifest files. You can change it via the appDir config option:

// addfox.config.ts
export default defineConfig({
  appDir: "src",  // Change to src directory
});
Multi-file structure (recommended)
Single-file structure
app/
├── background/
│   └── index.ts          # Service Worker / background script
├── content/
│   └── index.ts          # Content script
├── popup/
│   ├── index.html        # Popup HTML (optional)
│   └── index.ts          # Popup script
├── options/
│   ├── index.html        # Options HTML (optional)
│   └── index.ts          # Options script
├── sidepanel/
│   └── index.ts          # Side panel
├── manifest/
│   ├── manifest.json           # Base configuration
│   ├── manifest.chromium.json  # Chrome overrides
│   └── manifest.firefox.json   # Firefox overrides
└── ...
Info

For more about entry discovery rules, see File-based Entry and entry config.

public Directory

public/ is for static assets, which are copied as-is to the output directory during build without processing:

public/
├── icons/                # Extension icons
│   ├── icon16.png
│   ├── icon48.png
│   └── icon128.png
├── _locales/             # Internationalization files
│   └── zh_CN/
│       └── messages.json
└── welcome.html          # Welcome page

When referencing these resources in code, use paths relative to the output root:

// Reference public/icons/icon16.png
const iconPath = "icons/icon16.png";

Entry Types

Addfox supports the following built-in entries:

Entry NameTypeDescriptionGenerates HTML
backgroundScript onlyService Worker / background scriptNo
contentScript onlyContent scriptNo
popupScript + PageToolbar popupYes
optionsScript + PageExtension options pageYes
sidepanelScript + PageSide panelYes
devtoolsScript + PageDeveloper toolsYes
offscreenScript + PageOffscreen documentYes
Warning

Built-in entry names cannot be changed, as Addfox relies on them for automatic recognition.

Configuration Files

addfox.config.ts / addfox.config.js

This is the required configuration file for Addfox, used to declare:

  • Extension manifest
  • Entry files
  • Output directory
  • Rsbuild plugins and configuration

Minimal Configuration Example

import { defineConfig } from "addfox";

export default defineConfig({
  // When omitted, framework auto-discovers entries and manifest from app/
});
  • appDir — Customize application directory
  • entry — Manually configure entries
  • outDir — Customize output directory
  • manifest — Manifest configuration methods