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

sw-bundler-plugin

v1.0.0

Published

*yet another Webpack plugin for the Service-Workers*

Downloads

5

Readme

sw-bundler-plugin

yet another Webpack plugin for the Service-Workers

A service-workers bundler for Webpack.

What is it?

This plugin is using the Google Chrome module sw-precache. It generates your pre-cache SW script. If you have some custom service-worker usage (asynchronous storage strategy for your frontend, notifications ...) the plugin bundles all your scripts in one single file.

Why?

Because you can execute only one service-worker on your website.

How does it work?

Go to your project. Run the following command:

npm i --save-dev sw-bundler

Open your Webpack config and add the following configuration:

module.exports = {
  // ... your config
  plugins: [
    new SWBundlerPlugin({
      assetsRootdir: 'examples',
      filename: `test-generator.${Date.now().toString(10)}.js`,
      swsDir: './examples/sws',
    }),
  ],
}

The swsDir is the directory where your SW scripts are. The plugin will list all the files in this directory and bundle them with the output of the sw-precache module.

How to test it?

Clone the project and run npm run test. The unit-tests try to be as close as possible to the real use-case you could have. If you want a real life demo run the following commands after cloning the repository:

$> npm i
$> $(npm bin)/webpack
$> npm run serve

It will open a new tab in your browser. Checkout the console (the application tab) and enjoy !

Documentation

Configuration

The plugin accepts an object as configuration. Here are some of the properties you could set:

  • assetsRootdir: the directory with your assets (default : process.cwd())
  • filename: the name of the file to output (default: sw.timestamp.js where timestamp is equal to Date.now()). If you plan to use a custom filename, do not forget to integrate a value for invalidating the old version of your file.
  • swsDir: The directory where your custom Service Worker scripts are stored
  • webpackOpts: Some extra configuration for Webpack (e.g.: Babel, minification ...)
  • swprecacheOpts: some extra options for the sw-precache module (see this page for more information)

Contributing - Complaining

If you found a bug or think that something is missing, do not hesitate to open a issue or a pull-request