Chrome Extension Boilerplate
A basic foundation boilerplate for rich Chrome Extensions. 中文文档
Features
This repro is built under the inspiration of chrome-extension-webpack-boilerplate,but has some extra & useful features:
- All the libraries used are the latest version:
webpack v4, react v15
- Support less
- A more standard directory structure
Use
- Check if your Node.js version is >= 8.
- Clone the repository.
- Install npm.
- Run
npm i
. - Change the package's name and description on
package.json
. - Change the name of your extension on
src/manifest.json
&&replace icons onsrc/images
. - Run
npm run dev
- Load your extension on Chrome following:
- Access
chrome://extensions/
- Check
Developer mode
- Click on
Load unpacked extension
- Select the
dist
folder.
- Access
- Have fun!.
Structure
All your extension's development code must be placed in src
folder, including the extension manifest.
The boilerplate is already prepared to have a popup, a options page and a background page. You can easily customize this.
Packing
After the development of your extension run the command
$ npm run build
Now, the content of dist
folder will be the extension ready to be submitted to the Chrome Web Store. Just take a look at the official guide to more infos about publishing.
Secrets
If you are developing an extension that talks with some API you probably are using different keys for testing and production. Is a good practice you not commit your secret keys and expose to anyone that have access to the repository.
To this task this boilerplate import the file ./secrets.<THE-NODE_ENV>.js
on your modules through the module named as secrets
, so you can do things like this:
./secrets.development.js
export default { key: "123" };
./src/popup.js
import secrets from "secrets";
ApiCall({ key: secrets.key });
👉 The files with name secrets.*.js
already are ignored on the repository.
Thanks
Todo
- redux
- webpack dev server
- use
copy-webpack-plugin
to generates the manifest file using thepackage.json
informations
License
MIT