GithubHelp home page GithubHelp logo

fossabot / webpack-webextension-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from webextension-toolbox/webpack-webextension-plugin

0.0 1.0 0.0 40 KB

Webpack plugin that compiles web-extension manifest.json files and adds smart auto reload

Home Page: https://www.npmjs.com/package/webpack-webextension-plugin

License: Other

JavaScript 100.00%

webpack-webextension-plugin's Introduction

webextension-webpack-plugin

WebextensionWebpackPlugin

npm package build status FOSSA Status

dependencies devDependencies JavaScript Style Guide license Build status

Webpack plugin that compiles web-extension manifest.json files and adds smart auto reload.

What does it do?

  • Autoreload extensions via websockets
  • Use vendor prefixes in manifest properties
  • Validates some manifest.json fields

Install

$ npm i webpack-webextension-plugin

Usage

const WebextensionPlugin = require('webpack-webextension-plugin')

const config = {
  plugins: [
    new WebextensionPlugin({
      vendor: 'chrome'
    })
  ]
}

API

new WebextensionPlugin([options])

Add result to webpack plugins to initialize.

options

Type: Object

Any of the options below.

vendor

Type: String
Default: chrome
Any of: chrome, opera, firefox, edge

Used for vendor prefixing in the manifest.json. More infos regarding this can be found below.

port

Type: Integer
Default: 35729

Specify the listening port for the webstocket development server.

autoreload

Type: Boolean
Default: true

Enables auto reload. If not specified will be enabled when using webpacks watch mode.

quiet

Type: Boolean
Default: false

Disable plugin logging.

reconnectTime

Type: Integer
Default: 3000

Specify the reconnect time to the development server from the extension side.

manifestDefaults

Type: Object
Default: {}

Allows you to define defaults for the manifest.json file.

FAQ

How does smart autoreload work?

We create/extend a background page in the extension with a websockets client, that connects to our custom websocket server. As soon as a specific files changes the client checks how to reload the extension:

  • if manifest.json change → full reload
  • if manifest.json dependencies change → full reload
  • if _locales change → full reload
  • else reload current tab & all extension views

What are vendor prefixed manifest keys?

Vendor prefixed manifest keys allow you to write one manifest.json for multible vendors.

{
  "__chrome__name": "SuperChrome",
  "__firefox__name": "SuperFox",
  "__edge__name": "SuperEdge",
  "__opera__name": "SuperOpera"
}

if the vendor is chrome this compiles to:

{
  "name": "SuperChrome",
}

Add keys to multiple vendors by seperating them with | in the prefix

{
  __chrome|opera__name: "SuperBlink"
}

if the vendor is chrome or opera, this compiles to:

{
  "name": "SuperBlink"
}

Why are you not using mozillas web-ext package?

  • webpack-webextension-plugin should work for every browser in the same way.
  • web-ext only works for firefox. Nevertheless if your primary browser is firefox, you should definetly check it out.

Links

License

Copyright 2018 Henrik Wenz

This project is free software released under the MIT license.

FOSSA Status

webpack-webextension-plugin's People

Contributors

balcsida avatar erictrinh avatar fossabot avatar greenkeeper[bot] avatar handtrix avatar renovate-bot avatar

Watchers

 avatar

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.