This template should help get you started developing a svelte web extension in Vite.
The extension manifest is defined in src/manifest.js
and used by @samrum/vite-plugin-web-extension
in the vite config.
Background, content scripts, options, and popup entry points exist in the src/entries
directory.
Content scripts are rendered by src/entries/contentScript/renderContent.js
which renders content within a ShadowRoot
and handles style injection for HMR and build modes.
Otherwise, the project functions just like a regular Vite project.
Refer to @samrum/vite-plugin-web-extension for more usage notes.
See Vite Configuration Reference.
npm install
Use file extension
in the Code Styles options should be never
.
Hot Module Reloading is used to load changes inline without requiring extension rebuilds and extension/page reloads
npm run dev
Rebuilds extension on file changes. Requires a reload of the extension (and page reload if using content scripts)
npm run watch
Minifies and optimizes extension build
npm run build
Loads the contents of the dist directory into the specified browser
npm run serve:chrome
npm run serve:firefox