npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@webextension-toolbox/webpack-webextension-plugin

v3.3.1

Published

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

Downloads

3,174

Readme

Webpack WebExtension Plugin

npm package license

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

If you are looking for a simple CLI tool that utilizes this checkout https://github.com/webextension-toolbox/webextension-toolbox

What does it do?

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

Install

$ npm i @webextension-toolbox/webextension-toolbox

Usage

import WebextensionPlugin from "@webextension-toolbox/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, safari

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.

skipManifestValidation

Type: Boolean Default: false

Skip Manifest Validation

FAQ

How does smart autoreload work?

We create/extend a background page or service worker in the extension with a websockets client if autoreload is true the webpack is watching, 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",
  "__safari__name": "SuperSafari"
}

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"
}

Environment Variable Replacement in Manifest

{
  "name": "__MY_ENV_VARIABLE__",
}

Would be replaced with the value of process.env.MY_ENV_VARIABLE

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 with Chrome and Firefox. You should definitely still check it out.

Links

License

Copyright 2018-2022 Henrik Wenz

This project is free software released under the MIT license.