All Projects → samuelsimoes → Chrome Extension Webpack Boilerplate

samuelsimoes / Chrome Extension Webpack Boilerplate

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

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Chrome Extension Webpack Boilerplate

Vue Chrome Extension Boilerplate
Boilerplate for Chrome extension using Vue.js and Webpack with auto-reload enabled.
Stars: ✭ 171 (-87.05%)
Mutual labels:  webpack, boilerplate, chrome-extension
Awesome Chrome Extension Boilerplate
Use react + typescript + webpack to enhance your chrome extension development experience
Stars: ✭ 146 (-88.94%)
Mutual labels:  webpack, boilerplate, chrome-extension
Web Extension Starter
Typescript, React, Redux, Styled-Component and Webpack based sample extension boilerplate. Runs on Chrome and Firefox. Sample chrome extension.
Stars: ✭ 115 (-91.29%)
Mutual labels:  webpack, boilerplate, chrome-extension
Chrome Extension React Typescript Boilerplate
🔨 A boilerplate project to quickly build a Chrome extension using TypeScript and React (built using webpack).
Stars: ✭ 347 (-73.71%)
Mutual labels:  webpack, boilerplate, chrome-extension
React Cool Starter
😎 🐣 A starter boilerplate for a universal web app with the best development experience and a focus on performance and best practices.
Stars: ✭ 1,083 (-17.95%)
Mutual labels:  webpack, boilerplate
React Boilerplate
Production-ready boilerplate for building universal web apps with React and Redux
Stars: ✭ 53 (-95.98%)
Mutual labels:  webpack, boilerplate
Html5 Boilerplate
A simple, fast, modern, pure html, css (and sass), js, live reload starter template
Stars: ✭ 65 (-95.08%)
Mutual labels:  webpack, boilerplate
Jolly
Production ready boilerplate for hapi.js
Stars: ✭ 68 (-94.85%)
Mutual labels:  webpack, boilerplate
Tris Webpack Boilerplate
A Webpack boilerplate for static websites that has all the necessary modern tools and optimizations built-in. Score a perfect 10/10 on performance.
Stars: ✭ 1,016 (-23.03%)
Mutual labels:  webpack, boilerplate
React Universal Boiler
A bold way to begin your next great universal React application. Uses Webpack 3, React 16, Redux, and more for a great developer experience.
Stars: ✭ 65 (-95.08%)
Mutual labels:  webpack, boilerplate
Flask React Boilerplate
Simple boilerplate for a Flask backend and React client
Stars: ✭ 69 (-94.77%)
Mutual labels:  webpack, boilerplate
Express React Hmr Boilerplate
A boilerplate for scaffolding production-ready MERN stack projects.
Stars: ✭ 51 (-96.14%)
Mutual labels:  webpack, boilerplate
Webxr Webpack Boilerplate
Starter Kit for building rich, immersive WebXR projects (featuring A-Frame) PWA with Webpack and SASS
Stars: ✭ 48 (-96.36%)
Mutual labels:  webpack, boilerplate
React Redux Typescript Boilerplate
A bare minimum frontend boilerplate with React 16, Typescript 3 and Webpack 4
Stars: ✭ 1,100 (-16.67%)
Mutual labels:  webpack, boilerplate
Webvr Webpack Boilerplate
A webvr multi-scenes Single-page application for three.js, webpack
Stars: ✭ 47 (-96.44%)
Mutual labels:  webpack, boilerplate
App Template
Boilerplate for Angular apps
Stars: ✭ 67 (-94.92%)
Mutual labels:  webpack, boilerplate
React Webpack Babel
Simple React Webpack Babel Starter Kit
Stars: ✭ 1,241 (-5.98%)
Mutual labels:  webpack, boilerplate
Mern
🎉 This is boilerplate for MERN stack with integrations like Redux and SSR 🎉
Stars: ✭ 77 (-94.17%)
Mutual labels:  webpack, boilerplate
React Ssr Boilerplate
A boilerplate for server-side rendered React Applications. Includes local auth and GitHub Oauth 2 strategies.
Stars: ✭ 85 (-93.56%)
Mutual labels:  webpack, boilerplate
Phaser3 Tilemap Pack
Phaser 3 Project Template with Webpack, Tilemap, and Asset Pack
Stars: ✭ 87 (-93.41%)
Mutual labels:  webpack, boilerplate

Chrome Extension Webpack Boilerplate

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

Developing a new extension

I'll assume that you already read the Webpack docs and the Chrome Extension docs.

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

Each page has its own assets package defined. So, to code on popup you must start your code on src/js/popup.js, for example.

You must use the ES6 modules to a better code organization. The boilerplate is already prepared to that and here you have a little example.

Webpack auto-reload and HRM

To make your workflow much more efficient this boilerplate uses the webpack server to development (started with yarn run server) with auto reload feature that reloads the browser automatically every time that you save some file o your editor.

You can run the dev mode on other port if you want. Just specify the env var port like this:

$ PORT=6002 yarn run start

Content Scripts

Although this boilerplate uses the webpack dev server, it's also prepared to write all your bundles files on the disk at every code change, so you can point, on your extension manifest, to your bundles that you want to use as content scripts, but you need to exclude these entry points from hot reloading (why?). To do so you need to expose which entry points are content scripts on the webpack.config.js using the chromeExtensionBoilerplate -> notHotReload config. Look the example below.

Let's say that you want use the myContentScript entry point as content script, so on your webpack.config.js you will configure the entry point and exclude it from hot reloading, like this:

{
  
  entry: {
    myContentScript: "./src/js/myContentScript.js"
  },
  chromeExtensionBoilerplate: {
    notHotReload: ["myContentScript"]
  }
  
}

and on your src/manifest.json:

{
  "content_scripts": [
    {
      "matches": ["https://www.google.com/*"],
      "js": ["myContentScript.bundle.js"]
    }
  ]
}

Packing

After the development of your extension run the command

$ NODE_ENV=production yarn run build

Now, the content of build 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.

With React.js

💡 If you want use React.js with this boilerplate, check the react branch.

Contributing

  1. Please!! Do not create a pull request without an issue before discussing the problem.
  2. On your PR make sure that you are following the current codebase style.
  3. Your PR must be single purpose. Resolve just one problem on your PR.
  4. Make sure to commit in the same style that we are committing until now on the project.

Samuel Simões ~ @samuelsimoes ~ Blog

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].