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

crx-reload-webpack-plugin

v1.0.3

Published

A webpack plugin for hot-reload chrome extension in develop

Downloads

6

Readme

A webpack plugin for hot-reload chrome extension in develop.

Befor I develop chrome extension, I found I need a tool to reload extension and website when extension files changed. I found two projects: wcer and crx-reload.But they not good enough, cann't accord different file change to reload, and wcer no longer update after 2018.1. So, I wirte the plugin for better develop chrome extension.

crx-reload-webpack-plugin is a webpack4 plugin for reload extension and website when your extension files changed.

Features:

  • auto listen manifest.js file change and generate corresponding manifest.json.
  • reload different website accord different file change.
    • manifest.js: reload the extension.
    • content: reaload all tab.
    • popup: just reload the popup.html tab.
    • background: just reload background.html tab.
    • options: just reload options.html tab.
    • custom: you can appoint listen files and injected file.

Install

npm i -D crx-reload-webpack-plugin

Usage:

const CrxReloadPlugin = require('crx-reload-webpack-plugin')

module.exports = {
  ...: ...,
  plugins: [
    new CrxReloadPlugin({
      manifest: path.resolve(__dirname, './src/manifest.js'),
      port: 9999, // the server port in plugin, be used for notice chrome reload
      path: {
        background: path.resolve(__dirname, './src/background/')
      }
    })
  ],
  ...: ...
}

Options type:

  • manifest: string (required)

    This is manifest file absolute path. The js file need export a object like manifest.json.

  • port: number (optional)

    Default is 9999. This is the server's port in plugin. The server is used for notice chrome reload.

  • path: object (optional)

    • background: Array<string>
    • options: Array<string>
    • popup: Array<string>
    • content: Array<string>

    This object is a collection of absolute paths. Plugin will listen these paths. For example:

    paths: {
      background: ['work/testExtension/src/background.js'],
      options: ['work/testExtension/src/options/'],
      popup: ['work/testExtension/src/popup.js','work/testExtension/src/popup.html'],
      content: ['work/testExtension/src/options.js']
    }

    When paths.options inclued files change, the options html tab reload, other field same. Its value is a string array, can include file or folder.

    Is's default value is:

    const context = webpackConfig.context // such as /work/testExtension/src
    paths: {
      background: [path.resolve(context, 'background')], // ../src/background/*
      options: [path.resolve(context, 'options')], // ../src/options/*
      popup: [path.resolve(context, 'popup')], // ../src/popup/*
      content: [path.resolve(context, 'content')] // ../src/content/*
    }
  • extraPaths Array<object> (optional)

    • name: string, is a key and it cann't repeat.
    • inject: string, is a path that is a js files , will be injected.
    • listens: Array<string>, is a array of path string, when these file changed, reload injected js and its html.
  • logLevel string (optional)

    Default is error, it is plugin log level, you can set to info to get plugin work detail.

  • autoRetry bollean (optional)

    Default is false. When server (in plugin) was stop, this decide client (Chrome) whether auto reconnect. You can manually reload background.js tab.

Example

You can reference template/ and config/webpack.extension.js. This is a basic extension develop structure.

PS:

I recommand you open chrome-extension://xxxxxxxxx/_generated_background_page.html page to develop background.js.Otherwise, reload background will failure, because in devtool page(default) cann't get tab's id to reload.