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

@auser/metalsmith-watch

v1.0.4

Published

Metalsmith plugin to watch for changes and trigger partial and full rebuilds

Downloads

7

Readme

metalsmith-watch Build Status NPM version

Metalsmith plugin to watch for changes and trigger partial and full rebuilds.

Installation

$ npm install metalsmith-watch

Usage

var metalsmith = require('metalsmith');
var watch = require('metalsmith-watch');

metalsmith(__dirname)
  .use(
    watch({
      paths: {
        "${source}/**/*": true,
        "templates/**/*": "**/*.md",
      },
      livereload: true,
    })
  )
  .build();

Options

paths (default: {"${source}/**/*": true})

Map of paths to trigger rebuild. Both keys and value accept a glob pattern.

{
  "file(s) to watch": "file(s) to rebuild"
}

Value accept a boolean. When a boolean is used, only watched files changed will be rebuilded.

{
  "${source}/**/*": true, // every changed files will trigger a rebuild of themselves
  "templates/**/*": "**/*", // every templates changed will trigger a rebuild of all files
}

Please note that:

  • ${source} is replaced by metalsmith.source().
  • values of the map are relative to metalsmith.source() (because it's the only place where to build files)

livereload (default: false)

Allows you to enable a livereload server. Using a boolean will enable a livereload server on port the default port is 35729. Accept a port number to start on the port you need.

To get live reload working properly, you should add the following <script> in your templates files to enable livereloading of each pages:

<script src="http://localhost:35729/livereload.js"></script>

Make sure to update the port number in the script above accordingly to the port specified.

onUpdateCallback (default: undefined)

Allows you to define a function to get called after metalsmith has reloaded all the files. If a function is passed, this will be called with the updated files and all options passed.

{
  onUpdateCallback: function (files, options) {
    // Called on every rebuild
  }
}

log (default: function(...args) { console.log(prefix, ...args)})

Function used to display the logs.

invalidateCache (default: true)

Allows you to enable cache invalidation for js files. Convenient if you use some js files for templates (eg: React templates) to get updated components. If disabled you won't get update for changed js files as node/iojs use a cache.

Changelog

License