merrier / chrome-extension-boilerplate

A basic foundation boilerplate for rich Chrome Extensions using Webpack & React to help you write modular and modern Javascript code, load CSS easily and automatic reload the browser on code changes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

  1. Check if your Node.js version is >= 8.
  2. Clone the repository.
  3. Install npm.
  4. Run npm i.
  5. Change the package's name and description on package.json.
  6. Change the name of your extension on src/manifest.json &&replace icons on src/images.
  7. Run npm run dev
  8. Load your extension on Chrome following:
    1. Access chrome://extensions/
    2. Check Developer mode
    3. Click on Load unpacked extension
    4. Select the dist folder.
  9. 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 the package.json informations

License

MIT

About

A basic foundation boilerplate for rich Chrome Extensions using Webpack & React to help you write modular and modern Javascript code, load CSS easily and automatic reload the browser on code changes.

License:MIT License


Languages

Language:JavaScript 95.7%Language:Less 2.2%Language:HTML 2.2%