A Vite powered WebExtension (Chrome, FireFox, etc.) starter template.
Popup
Options Page
Inject Svelte App into the Content Script
- ⚡️ Instant HMR - use Vite on dev (no more refresh!)
- 💬 Effortless communications - powered by
webext-bridge
andsvelte-webext-stores
- 🍃 Windi CSS - on-demand CSS utilities
- 🦾 TypeScript - type safe
- 🌟 Icons - Access to icons from any iconset directly
- 🖥 Content Script - Use Svelte even in content script
- 🌍 WebExtension - isomorphic extension for Chrome, Firefox, and others
- 📃 Dynamic
manifest.json
with full type support
webextension-polyfill
- WebExtension browser API Polyfill with typeswebext-bridge
- effortlessly communication between contexts
unplugin-auto-import
- Directly usebrowser
and Svelte runtime API without importingunplugin-icons
- icons as componentsvite-plugin-windicss
- WindiCSS support
svelte-webext-stores
- a Svelte store backed bybrowser.storage
- Windi CSS - next generation utility-first CSS framework
- ESLint with the SvelteKit defaults (as of the time of writing)
- TypeScript
- pnpm - fast, disk space efficient package manager
- esno - TypeScript / ESNext node runtime powered by esbuild
- npm-run-all - Run multiple npm-scripts in parallel or sequential
- web-ext - Streamlined experience for developing web extensions
Create a repo from this template on GitHub.
If you prefer to do it manually with the cleaner git history
If you don't have pnpm installed, run: npm install -g pnpm
npx degit ohmree/sveltesse-webext my-webext
cd my-webext
pnpm i
src
- main source.contentScript
- scripts and components to be injected ascontent_script
background
- scripts for background.components
- Svelte components that are shared in popup and options page.styles
- styles shared in popup and options pageassets
- static assets.
dist
- extension root (contains built files, also serve stub entry for Vite on development).scripts
- development and bundling helper scripts.manifest.ts
- manifest for the extension.
pnpm dev
Then load extension in browser with the dist/
folder.
For Firefox developers, you can run the following command instead:
pnpm start:firefox
web-ext
auto reload the extension when dist/
files changed.
While Vite handles HMR automatically in the most of the case, Extensions Reloader is still recommanded for cleaner hard reloading.
To build the extension, run
pnpm release:firefox
or
pnpm release:chromium
And then pack files under dist
, you can upload extension.crx
or extension.xpi
to appropriate extension store.
This is a Svelte port of Vitesse WebExt and owes everything to it, check out Vitesse's full variations list.