Skip to content

Project Structure

Top-level Folder

Top-level folder is used to organize the following files or folders.

NameDescription
public/Static assets to be copyed to dist directly
src/Source folders
.web-extend/Temp folder for WebExtend
.envLoaded by default in all scenarios.
.env.localLocal usage of the .env file, should be added to .gitignore
.env.developmentRead when process.env.NODE_ENV is 'development'
.env.productionRead when process.env.NODE_ENV is 'production'
.env.development.localLocal usage of the .env.development file, should be added to .gitignore
.env.production.localLocal usage of the .env.production file, should be added to .gitignore
.gitignoreGit files and folders to ignore
package.jsonProject dependencies and scripts
rsbuild.config.tsConfiguration file for Rsbuild
web-ext.config.jsConfiguration file for web-ext
tsconfig.jsonConfiguration file for TypeScript

Source Folder

Source folder is used to organize entrypoints, components, lib, etc folders or files.

NameDescription
assets/Static assets to be processed by the build tool
backgroundBackground entry
content or contentsContent entry
popupPopup entry
optionsOptions entry
sidepanelSidepanel entry
devtoolsDevtools entry
sandbox or sandboxesSandbox entry
newtabNewtab entry
bookmarksBookmarks entry
historyHistory entry

Manifest Mapping

There is no need to maintain manifest.json manually. WebExtend generates it automatically based on the file system. The mapping relationship is as follows.

Manifest KeysThe Mapping Path
manifest_versiondefaults to 3
namedisplayName or name in package.json
versionversion in package.json
descriptiondescription in package.json
authorauthor in package.json
homepage_urlhomepage in package.json
iconsaction.default_iconsrc/assets/icon-[size].png
action.default_popupsrc/popup.js or src/popup/index.js
background.service_workersrc/background.js or src/background/index.js
content_scriptssrc/content.js or src/contents/*.js
options_ui.pagesrc/options.js or src/options/index.js
devtools_pagesrc/devtools.js or src/devtools/index.js
sandbox.pagessrc/sandbox.js or src/sandboxes/*.js
chrome_url_overrides.newtabsrc/newtab.js or src/newtab/index.js
chrome_url_overrides.bookmarkssrc/bookmarks.js or src/bookmarks/index.js
chrome_url_overrides.historysrc/history.js or src/history/index.js
side_panel.default_pathsrc/sidepanel.js or src/sidepanel/index.js
_localespublic/_locales/*
web_accessible_resourcespublic/*

Custom Configuration

WebExtend also supports custom settings for the source folder, the dist folder, etc.

js
import { defineConfig } from '@rsbuild/core';
import { pluginWebExtend } from '@web-extend/rsbuild-plugin';

export default defineConfig({
  plugins: [
    pluginWebExtend({
      srcDir: "src", // default: "src"
      outDir: "dist", // default: "dist/[target]-[mode]"
      manifest: {...}, // default: {}
      target: "firefox-mv2", // default: "chrome-mv3"
    }),
  ],
});

Released under the MIT License.