How lxieyang/chrome-extension-boilerplate-react works
Project type & purpose
• This is a Chrome Extension (Manifest V3) boilerplate built with React 18 and Webpack 5.
• It supplies multiple extension entry points (popup, options page, new tab, devtools panel, background service worker, content script, in-extension panel) all bundled via Webpack.
A. Developer & Build Pipeline (local machine)
• Node.js & npm scripts (package.json)
• Webpack config (webpack.config.js) driving:
• Multiple entry points: popup, options, newtab, background, content, devtools, panel
• React Refresh & HMR in dev (react-refresh-webpack-plugin)
• Production bundling (npm run build → build/ folder)
• Utility scripts under utils/:
• build.js (custom build orchestration)
• webserver.js (dev server)
• env.js (env var injection)
B. Build Output (build/ folder)
• manifest.json (extension manifest)
• Bundled JS/CSS for each entry
C. Runtime contexts inside Chrome
1. Service Worker (Background)
• Source: src/pages/Background/index.js
• Managed by MV3; event-driven, listens to chrome.runtime.onMessage
2. Content Script
• Source: src/pages/Content/index.js + modules/print.js
• Injected into web pages via content_scripts in manifest.json
3. Popup UI
• Source: src/pages/Popup/*.jsx, index.html
4. Options Page
• Source: src/pages/Options/*.tsx, index.html
• Configurable settings UI
5. New Tab Override
• Source: src/pages/Newtab/*.jsx, index.html
• Replaces browser’s new tab page
6. DevTools Panel
• Source: src/pages/Devtools/index.html + index.js
• Embedded in Chrome DevTools via devtools_page manifest key
7. In-Page Panel
• Source: src/pages/Panel/*.tsx, index.html
• A sidebar/panel inside the browser UI or a host page
D. Shared code & assets
• React “Greetings” container (src/containers/Greetings/Greetings.jsx)
• Global styles, images (src/assets/img)
• TypeScript config (tsconfig.json) for Options & Panel
Architectural patterns & principles
• Modular multi-entry bundling: each extension page gets its own bundle
• MV3 event-driven background service worker instead of persistent background page
• Separation of concerns: UI pages (React) vs. background logic (vanilla JS service worker) vs. content scripts
• HMR in dev environment; full static build in production
• Type-safe pages (Options/Panel) via TypeScript