A modern Chrome extension starter template powered by Vite, Svelte 5, TypeScript, TailwindCSS, and DaisyUI. This template is designed for rapid development of MV3 (Manifest Version 3) extensions with a focus on performance, modularity, and modern developer tools.
Before you begin, ensure you have the following installed:
Clone the Repository:
git clone https://github.com/your-username/chrome-extension-starter.git
cd chrome-extension-starter
Install Dependencies:
Using npm:
npm install
Or using pnpm:
pnpm install
Run Development Server:
npm run dev
This will start the Vite dev server for live reloading and hot module replacement (HMR). The extension will be pre-rendered for Chrome MV3 development.
Build for Production:
npm run build
The production-ready extension will be output to the dist/
directory.
chrome://extensions
in your browser.dist/
folder generated by the build process..
βββ public/ # Static assets (manifest.json, icons)
βββ src/
β βββ background/ # Background scripts
β βββ content/ # Content scripts for injecting into web pages
β βββ popup/ # Popup UI components
β βββ lib/ # Reusable components and utilities
β βββ options/ # Options page components
β βββ styles/ # TailwindCSS styles
β βββ types/ # TypeScript declarations
β βββ main.ts # Entry point for the application
βββ tailwind.config.js # TailwindCSS configuration
βββ tsconfig.json # TypeScript configuration
βββ vite.config.ts # Vite configuration
βββ postcss.config.js # PostCSS plugins (for TailwindCSS)
βββ package.json # Project dependencies and scripts
The manifest.json file is located in the public/
directory and defines the Chrome extensionβs permissions and entry points.
Key Settings:
{
"manifest_version": 3,
"name": "Chrome Extension Starter",
"version": "0.0.1",
"description": "A modern Chrome extension template with Svelte, Vite, TypeScript, TailwindCSS, and DaisyUI.",
"action": {
"default_popup": "popup/index.html",
"default_icon": "icons/icon-128.png"
},
"background": {
"service_worker": "background.js"
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content/index.js"]
}
],
"permissions": ["storage", "tabs"],
"icons": {
"16": "icons/icon-16.png",
"48": "icons/icon-48.png",
"128": "icons/icon-128.png"
}
}
Customizing Tailwind:
Edit the tailwind.config.js
file to add your themes, colors, or plugins.
module.exports = {
content: ["./src/**/*.{html,js,svelte,ts}"],
theme: {
extend: {},
},
plugins: [require("daisyui")],
};
DaisyUI Example:
<script>
let count = $state(0);
</script>
<div class="p-4 bg-base-200">
<button class="btn btn-primary" onclick={() => count++}>
Increment: {count}
</button>
</div>
npm run dev
: Start the development server with HMR.npm run build
: Build the extension for production.npm run preview
: Preview the built extension locally.vite.config.ts
)The project uses Vite for bundling. Customizations can be added in vite.config.ts
.
import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
export default defineConfig({
plugins: [svelte()],
build: {
rollupOptions: {
input: {
popup: "./src/popup/index.html",
background: "./src/background/index.ts",
content: "./src/content/index.ts",
},
},
},
});
If you encounter any issues or bugs, please file an issue in the GitHub repository.
This project is licensed under the MIT License.