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

@firstfleet/auto-reload-brunch

v4.1.0

Published

Fork of brunch/auto-reload-brunch. Adds automatic browser reloading support to brunch.

Downloads

32

Readme

auto-reload-brunch

This is a fork of the officia brunch plugin, changes or additions will be listed in the Additions sections of these docs.

Adds automatic browser reloading support to Brunch when using the brunch watch command.

The plugin uses WebSocket technology to pass compile events to browser.

Additions

  1. Converted from Commonjs to ESM (ES module). Will NOT work with the official brunch package. made to be used with @firstfleet/brunch, which has been converted to work with commonjs and esm plugins.
  2. Added a tag cleanup step the the stylesheet reloader in the auto-reload.js file. This allows HMR reloading for svelte and tailwinds, or other framework that inject tags into the app.

Usage

Install the plugin via npm with

npm install --save-dev auto-reload-brunch

In most cases, auto-reload-brunch works out of the box without any further configuration. Stylesheet changes will be applied seamlessly, and any other changes will trigger a page refresh. To prevent a stylesheet from being reloaded automatically, set the data-autoreload="false" attribute on the stylesheet's link tag.

Brunch plugin settings

If customization is needed or desired, settings can be modified in your brunch config file (such as brunch-config.coffee):

  • enabled: (Boolean or Object) Defaults to true
    • As a boolean, turn on Auto-Reloading for any change in your project, or off entirely.
    • As an object, enable Auto-Reloading for specific types of changes. Keys are the file extensions of compiled files (js or css) or assets to cover any other watched files that do not get compiled. When an object is used, only the types explicitly set to true will trigger an Auto-Reload.
  • port: (Integer or Array of Integers) Defaults to [9485..9495]
    • The port to run the WebSocket server on. It will be applied automatically on the server and the client.
    • If an array, it will use the first value, but automatically fail over to the next value in the array if the attempted port is already in use on the system. This allows multiple instances to run without conflict.
  • delay: (Integer, in milliseconds) Optional, no default
    • If your system is having race-condition type problems when the browser tries to reload immediately after a compile, use this to set a delay before the reload signal is sent.
  • host: (Default: '0.0.0.0') Server's host address.
  • forceRepaint: (Default: false) forcefully repaint the page after stylesheets refresh. Enabled in Chrome by default to mitigate the issue when it doesn't always update styles.
  • keyPath: Optional, no default.
    • Path to private key used for SSL.
  • certPath: Optional, no default.
    • Path to public x509 certificate.
  • forcewss: Optional, no default.
    • make the client always use wss:// instead of ws://.

Example:

module.exports = {
  // ...
  // All settings are optional
  plugins: {
    autoReload: {
      enabled: {
        css: true,
        js: true,
        assets: false
      },
      port: [1234, 2345, 3456],
      delay: require('os').platform() === 'win32' && 200,
      keyPath: 'path/to/ssl.key',
      certPath: 'path/to/ssl.crt',
      forcewss: true
    }
  }
};

Client-side settings

If your brunch watch is running on a different machine than your preview screen, you can set server config variable to connect to a brunch/websocket server running at another ip address.

<script>
  window.brunch = window.brunch || {};
  window.brunch.server = '192.168.1.2';
</script>

You can also set the port (single integer only) and/or disable auto-reload via client-side scripting, although generally it's a better idea to use brunch config for this:

window.brunch['auto-reload'] = window.brunch['auto-reload'] || {};
window.brunch['auto-reload'].port = 1234
window.brunch['auto-reload'].disabled = true;

Custom file extensions

You can configure what extensions count as stylesheet and javascript reloads. By default, any compile file with an extension other than .css or .js will do a full page reload. The match option allows you to issue efficient stylesheet-only reloads for other file extensions as well.

The value of match.stylesheets and match.javascripts is an anymatch set, and so can be a wildcard, regexp, function, or an array thereof.

module.exports = {
  // ...
  plugins: {
    autoReload: {
      match: {
        stylesheets: ['*.css', '*.jpg', '*.png'],
        javascripts: ['*.js']
      }
    }
  }
};

License

The MIT License (MIT)

Copyright (c) 2012-2017 Paul Miller (http://paulmillr.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.