This Chrome extension template comes with the following features and tools:
- TypeScript for type safety.
- pnpm as the package manager.
- Vite for fast development and build setup.
- React for building UI components.
- TailwindCSS for styling.
- Service Worker for background tasks.
- Content Script for interacting with web pages.
"@"
as a path alias for cleaner imports.- Include Auto-Build Script
./scripts/watch-build.sh
- Pre-configured and ready to use.
- Battle-tested for reliability.
Here are some important files you might want to review:
vite.config.ts
: Configuration for Vite.public/manifest.json
: The extension's manifest file.package.json
: Project dependencies and scripts.tailwind.config.js
: Configuration for TailwindCSS.
To compile the project, navigate to the root directory and run:
pnpm build
This will create a build
folder. You can use this folder to Load Unpacked
in chrome://extensions/
.
For automatic builds whenever you make changes, use the watch-build.sh
script located in the scripts
folder.
-
Make the script executable:
chmod +x ./scripts/watch-build.sh
-
Run the script:
./scripts/watch-build.sh . 'pnpm build'
This will rebuild the project every time you make updates.
When working with content-script.js
and service-worker.js
, you need to use two different Chrome consoles.
- Use the standard Chrome DevTools console.
- Inspect any website where your content script is running to access the console.
To access the console for service-worker.js
:
- Navigate to
chrome://extensions/
. - Enable Developer mode (toggle it at the top-right corner).
- Find your extension on the same page and click Inspect views: service worker.
- A new developer console will open, where you can view logs and debug your service worker.
Code released under the MIT License.