How jonghakseo/chrome-extension-boilerplate-react-vite works
Main Components
• Chrome Extension Core:
• Pages Layer:
• Under “pages/”, there are folders for different extension entry points: content scripts (pages/content, pages/content-ui, pages/content-runtime), popup, options, new-tab, side-panel, devtools, and devtools-panel. Each is built as its own mini-application that integrates with the extension manifest.
• Shared and Utility Packages:
• The “packages/” directory includes several modules that handle various concerns:
▪ dev-utils – helper utilities like manifest parsing and logging.
▪ env – environment variable management.
▪ hmr – custom hot module reload mechanism for fast development.
▪ i18n – internationalization support.
▪ shared – common React components, hooks, types, and utilities.
▪ storage – abstractions over Chrome extension storage (local/session).
▪ tailwind-config – shared TailwindCSS setup.
▪ tsconfig, ui, vite-config, zipper, and module-manager provide shared configuration, UI merging, build systems, and module management.
• Build & Development Tools:
• Bash scripts provide automation for environment management and version updates.
• The “tests” directory contains end-to-end testing setups with WebdriverIO.
Relationships and Data Flow
• The Chrome extension’s Manifest (generated from chrome-extension/manifest.ts) serves as the coordination point dictating which pages (content, popup, options, etc.) are loaded.
• Each “pages” component is bundled separately via Vite with its own configuration (vite.config.mts) and then referenced within the manifest.
• The shared “packages” provide common functionality to be consumed by both the chrome-extension scripts and pages. This modular approach lets these components share types, environment variables, styling (via Tailwind), and HMR behaviors.
• Development and build processes (controlled by Turborepo, pnpm, and rollup configurations) manage building all packages and pages in a coordinated manner.
• Additionally, there are separate testing flows defined under “tests/e2e” that simulate user interactions across these components.
Architectural Patterns and Design Principles
• Modular Architecture with separation of concerns:
• Splitting extension-specific code (chrome-extension), runtime pages, and shared libraries (packages) leads to high modularity and reusability.
• Monorepo management:
• Turborepo is used to manage interdependent packages and simplify dependency management.
• Micro-frontend elements:
• Each page (popup, options, new-tab, etc.) functions as an individual mini-application that interacts via the Chrome extension runtime.
• Build and Dev Workflow Separation:
• Dedicated configurations and scripts for development (HMR, vite-dev server) and production builds, with CI workflows to enforce code quality (lint, prettier, etc.).
Relevant Technologies and Tools
• Frontend framework: React (for building UI in pages like popup, options, etc.).
• Language: TypeScript.
• Bundler: Vite (with Rollup for production builds).
• Styling: TailwindCSS.
• Automation: Bash scripts, Turborepo, pnpm.
• Testing: WebdriverIO (for E2E tests).
• Others: Prettier, ESLint, custom plugins (HMR, module-manager, i18n).