# watchalive

> Alive and robust file watcher with plugin system.

Latest version **1.1.9** (published 2016-02-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install watchalive
pnpm add watchalive
yarn add watchalive
bun add watchalive
```

Provides the command `watchalive`.

## 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.1.9 |
| Published | 2016-02-27 |
| First published | 2014-09-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 16 |
| Known vulnerabilities | 0 (+7 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | whitecolor |
| Keywords | javascript |

## Links

- npm: https://www.npmjs.com/package/watchalive
- Repository: https://github.com/whitecolor/watchalive
- Homepage: https://github.com/whitecolor/watchalive#readme
- Issues: http://github.com/whitecolor/watchalive/issues
- npm.io page: https://npm.io/package/watchalive

## Dependencies (16)

- [mime](https://npm.io/package/mime.md) ^1.3.4
- [async](https://npm.io/package/async.md) ^0.9.0
- [http2](https://npm.io/package/http2.md) ^3.2.0
- [yargs](https://npm.io/package/yargs.md) ^1.3.1
- [colors](https://npm.io/package/colors.md) ^0.6.2
- [express](https://npm.io/package/express.md) ^4.9.5
- [bluebird](https://npm.io/package/bluebird.md) ^2.9.11
- [chokidar](https://npm.io/package/chokidar.md) ^1.4.2
- [minimatch](https://npm.io/package/minimatch.md) ^2.0.1
- [socket.io](https://npm.io/package/socket.io.md) ^1.1.0
- [http-proxy](https://npm.io/package/http-proxy.md) ^1.6.0
- [on-headers](https://npm.io/package/on-headers.md) ^1.0.0
- [ua-parser-js](https://npm.io/package/ua-parser-js.md) ^0.7.3
- [cookie-parser](https://npm.io/package/cookie-parser.md) ^1.3.4
- [serve-favicon](https://npm.io/package/serve-favicon.md) ^2.1.5
- [express-session](https://npm.io/package/express-session.md) ^1.10.3

## Recent versions

- 1.1.9 (latest) — 2016-02-27
- 1.1.8 — 2016-02-05
- 1.1.7 — 2016-02-05
- 1.1.6 — 2016-02-03
- 1.1.5 — 2016-02-02
- 1.1.4 — 2016-01-31
- 1.1.3 — 2016-01-31
- 1.1.2 — 2016-01-17
- 1.1.1 — 2016-01-17
- 1.1.0 — 2016-01-07
- 1.0.5 — 2015-12-13
- 1.0.4 — 2015-09-15
- 1.0.3 — 2015-08-24
- 1.0.2 — 2015-08-19
- 1.0.1 — 2015-08-12
- … 42 more at https://npm.io/package/watchalive/versions

## README

# Watchalive.

A small but **robust dev server** with smart file watching and transform support.

## Generally:
- http express server
- lean and smart file watcher
- socket.io server and client

## Useful features:
- watches only served (requested by client) files
- transforms (transpiles/compiles) files on the fly using simple plugins
- handles custom routes
- proxies requests to other services
- client gets notified about changes including changed sources

If you have question you may ping on gitter 
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/whitecolor/watchalive?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge)

## Usage (CLI)

```bash
npm install watchalive -g
```

Place `watchalive.config.js` (or just `watchalive.js` or `wa.config.js` as you like) in your project folder. 
Run `"watchalive"` from command line.

Example configuration file (loading React.js transformed files with SystemJS loader):

```javascript
"use strict"
var babel = require('babel-core')

module.exports = {
    base: "..", // base serve directory, relative to process.cwd()
    skip: [/node_modules/], // won't watch, cache and transpile     
    plugin: [
        ["less", {paths: ['client']}], // standard less/css plugin
        [/\.js$/, (source) => // custom transformer
              babel.transform(source, {
                  presets: ["es2015", 'react'],
                  plugins: [
                      ['react-transform', {
                          transforms: [
                              {transform: 'react-transform-jspm-hmr'}
                          ]
                      }]
                  ]
              }).code 
        ]
    ],
    // advanced routing
    route: [
        {'/mobile': '/client/mobile/index.html'},
        {'*': '/client/web/index.html'}
    ],
    // flexible proxy config
    proxy: {
        '/api': 'my-app.dev:2000'
    },
    data: true // send source of changed file with notification message 
}
```
 
 You can also place config in `package.json` in `"watchalive"` section.
 
 Also you can run without config file:
 ```bash
 watchalive --port 7007 --base ..
 ```

### API usage

```bash
npm install watchalive
```

```javascript
"use strict"
const Watchalive = require('watchalive')
 
var wa = new Watchalive({/*config */})

wa.start()
```

[Deep dive into options!](lib/default-config.js)

### Client side usage
By default served *.html files get `watchalive.js` client script injected.
You can easily access to this notifications in code:
```javascript
    watchalive.onFiles(function(changes){
        // *changes* contain array of file names changed
        // can also contain changed file sources {file: ..., data: ...}
    })
``` 

### Examples of usage
- [CanJS hot reloading](https://github.com/whitecolor/can-hot)
- [Hot reloading with Steal-HMR](https://github.com/whitecolor/steal-hmr)

### Licence
MIT

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