Giter Site home page Giter Site logo

mathiscode / es6-webextension-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
4.0 0.0 0.0 696 KB

A boilerplate for writing WebExtensions in ES6 with Webpack and support for localization

License: MIT License

JavaScript 77.92% HTML 17.78% SCSS 4.30%
webextension firefox-addon chrome-extension es6-javascript i18n webpack boilerplate

es6-webextension-boilerplate's Introduction

ES6 WebExtension Boilerplate

Beerpay Beerpay Build Status GitHub license Standardjs PRs Welcome Tweet



Introduction

ES6 WebExtension Boilerplate is designed to get a new browser addon started quickly.

  • Ready-to-use development workflow from live-reload to publishing
  • Manifest version is automatically kept in sync with package.json version
  • Internationalization Utilities

Getting Started

Optional: You'll probably want to use this repository as a template, then replace the clone URL and directory name below.

git clone https://github.com/mathiscode/es6-webextension-boilerplate.git
cd es6-webextension-boilerplate
npm install # or yarn

Development

npm run develop # or yarn develop

This will cause webpack to watch for changes and automatically compile the extension, as well as automatically load your extension into Firefox using web-ext.

You can tweak the web-ext config in web-ext-config.js.

If you prefer to only start webpack in watch mode: npm start

Modifying

You will want to look at the following files and directories:

Building

npm run build # or yarn build

This will compile your code and create a ZIP file in the web-ext-artifacts directory that is ready to be uploaded to AMO or Chrome Web Store.

AMO requires that you submit the full source to be listed publicly, so the build command also zips the entire source into web-ext-artifacts/source.zip to be submitted with your extension.

Note: If your operating system doesn't provide a zip command, you will see a warning, but your source will still be zipped properly.

Version Sync

There is a utility to automatically keep your manifest version synced with your package.json version.

When incrementing your version, use the following commands:

  • npm run version:patch
    • to increment patch number
  • npm run version:minor
    • to increment minor number
  • npm run version:major
    • to increment major number

Internationalization

Internationalization is supported, and locale definitions are found in extension/_locales.

There is also a helper utility in src/utils/i18n.js that will allow you to localize your extension's HTML pages. This is done by default in the options and popup pages.

In the HTML, use the data-localize attribute to specify the message key to use; eg:

<h1 data-localize="__MSG_extensionName__"></h1>

To see this in action, refer to src/views/options and src/views/popup.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.