# metalsmith-watch

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

Latest version **1.0.3** (published 2016-06-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install metalsmith-watch
pnpm add metalsmith-watch
yarn add metalsmith-watch
bun add metalsmith-watch
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2016-06-07 |
| First published | 2014-03-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 59 |
| Maintainers | fweinb, moox |
| Keywords | metalsmith, metalsmith-plugin |

## Links

- npm: https://www.npmjs.com/package/metalsmith-watch
- Repository: https://github.com/FWeinb/metalsmith-watch
- Homepage: https://github.com/FWeinb/metalsmith-watch#readme
- Issues: https://github.com/FWeinb/metalsmith-watch/issues
- npm.io page: https://npm.io/package/metalsmith-watch

## Dependencies (7)

- [gaze](https://npm.io/package/gaze.md) ^1.0.0
- [async](https://npm.io/package/async.md) ^0.9.0
- [chalk](https://npm.io/package/chalk.md) ^1.0.0
- [tiny-lr](https://npm.io/package/tiny-lr.md) ^0.1.5
- [unyield](https://npm.io/package/unyield.md) 0.0.1
- [multimatch](https://npm.io/package/multimatch.md) ^2.0.0
- [metalsmith-filenames](https://npm.io/package/metalsmith-filenames.md) ^1.0.0

## Recent versions

- 1.0.3 (latest) — 2016-06-07
- 1.0.2 — 2016-05-16
- 1.0.1 — 2015-05-09
- 1.0.0 — 2015-05-08
- 0.2.0 — 2014-12-30
- 0.1.1 — 2014-05-05
- 0.1.0 — 2014-04-29
- 0.0.4 — 2014-04-15
- 0.0.3 — 2014-04-04
- 0.0.2 — 2014-03-10
- 0.0.1 — 2014-03-10

## README

# metalsmith-watch [![Build Status](https://travis-ci.org/FWeinb/metalsmith-watch.svg?branch=master)](https://travis-ci.org/FWeinb/metalsmith-watch) [![NPM version](http://img.shields.io/npm/v/metalsmith-watch.svg?style=flat)](https://www.npmjs.org/package/metalsmith-watch)

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

## Installation

```console
$ npm install metalsmith-watch
```

## Usage

```js
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](https://github.com/isaacs/node-glob).

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

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

```js
{
  "${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:

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

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

### 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](CHANGELOG.md)

## [License](LICENSE.md)

---
_Source: https://npm.io/package/metalsmith-watch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
