You can use this boilerplate code to start developing a Chrome extension using either JavaScript or TypeScript, Svelte for the frontend, Tailwind CSS for styling, Jest for testing, and Rollup as the build system.
This boilerplate also comes with automatic reloading during development with the help of rollup-plugin-chrome-extension. No more constantly refreshing the page to see your changes!
Type this into your terminal:
npx degit kyrelldixon/svelte-tailwind-extension-boilerplate
yarn
For development with automatic reloading:
yarn dev
Open the Extensions Dashboard, enable "Developer mode", click "Load unpacked", and choose the dist
folder.
When it's time to publish to Chrome, make a production build. Run the following line:
yarn build
This will create a ZIP file with your package name and version in the releases
folder.
This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:
node scripts/setupTypeScript.js
Or remove the script via:
rm scripts/setupTypeScript.js
Your manifest is at src/manifest.json
, and Rollup will bundle any files you
include here. All the filepaths in your manifest should point to files in src
.
src
├── background
│ └── index.js
├── content
│ └── index.js
├── manifest.json
└── popup
├── Counter.svelte
├── Counter.test.js
├── Popup.svelte
├── index.html
├── index.js
└── tailwind.css
Popup.svelte
will become the extension's "browser action" popuppopup/index.js
tells Popup
where to load in index.html
. It is also where Tailwind CSS gets loadedtailwind.css
is where you will add any custom tailwind stylesI wanted a boilerplate that would make it as easy as possible to get started building features and not setting up configurations. I also wanted the best possible extension development experience using modern tooling.
Special thanks to Jack and Amy at extend-chrome for making rollup-plugin-chrome-extension
. Check out their repos if you're really looking to make developing extensions and easier and more enjoyable experience.
Other repos that helped me build the boilerplate:
setupTypeScript.js
served as a reference for my own script.rollup-plugin-chrome-extension