The purpose of this project is to create an efficient Svelte Monorepo structure to develop complex Chrome Extensions that demand constant maintaining and improvement. I specifically chose Svelte over React or Angular as lack of Virtual DOM overhead when injecting custom components into web-pages makes a lot of sense to me. Svelte is just simple enough to minimize conflicts on arbitrary web pages while also being functional enough to make maintaining a large codebase easier.
ā Nx Workspace
ā Svelte 5
ā Typescript
ā Chrome Types
ā Live Reload
ā Very Fast Build
ā All In One Command
ā Support Manifest V3
ā Popup Page
ā Options Page
ā Devtools Panel
ā Background Script
ā Content Script
ā ShadCN-Svelte
ā Web Components (via Svelte Custom Elements and Lit)
ā Custom Elements Use Compiled Tailwind Styles
ā
Injected Tailwind Styles Replace rem
with em
to ignore the page root styles
ā Husky
ā Commitlint
ā Github Actions
ā Commitizen
ā Dark Mode
pnpm install
pnpm dev:all
chrome://extensions
"Developer mode"
"Load unpacked"
extension
directory from this root directoryā¹ļø More info about developing Chrome extension can be found here
Nx Workspace contributes significantly to clear project structure in this repository. There are 5 projects that are compiled to separate folders.
apps/popup
) - used for the upper popupapps/options
) - used for the options pageapps/devtools-panel
) - used for the devtools panelapps/scripts/background
) - used for tracking page updates and communicating with other parts of the application via Chrome message systemapps/scripts/content
) - used for monitoring of opened web-pages and injection of WebComponents.All the applications have already the Chrome types so can just use chrome
and the editor will recognize it.
The most important part of this project is the injection of Svelte-compiled web components into web pages, contained within /libs/custom-elements. I decided to use ShadCN to create reusable custom-elements. Injecting isolated, compiled Tailwind styles into the WebComponents (without breaking websites that use Tailwind) and getting development workflow with them to an acceptable level took most of development time.
It is also a part which I am least confident in, so any contribution would be appreciated.
Start with development configuration
pnpm dev:all
Start with production configuration.
pnpm prod:all
Build with development configuration.
npm run build:dev
Build with production configuration.
npm run build:prod
freeCodeCamp.org - for providing the idea for a bookmark app which organically touches on all aspects of Chrome Extension Development
Aviv Haruzi - For an example of a Chrome Extension project with Nx Workspace and providing the template for this README.