easy-livereload
This is yet another library to use livereload very easily for express/node.js-based development. It is express middleware which provides both a livereload server and a javascript client. It is designed to be used with node-dev so that restarting a server process is also possible.
The major features of this library include:
- using livereload (PROTOCOL 7) server code from the original author,
- using livereload.js client code from the original author,
- using fs.watch() to check file changes instantly,
- allowing to automatically restart server code (if invoked with node-dev), and
- all-in-one package to enable with at least one-line code.
Install
npm install easy-livereload node-dev
Usage
Minimal configuration:
app;
Typical configuration:
var path = ;var express = ;var app = ; if app === 'development' var livereload = ; var file_type_map = jade: 'html' // `index.jade` maps to `index.html` styl: 'css' // `styles/site.styl` maps to `styles/site.css` scss: 'css' // `styles/site.scss` maps to `styles/site.css` sass: 'css' // `styles/site.scss` maps to `styles/site.css` less: 'css' // `styles/site.scss` maps to `styles/site.css` // add the file type being edited and what you want it to be mapped to. ; // store the generated regex of the object keys var file_type_regex = '\\.(' + Object + ')$'; app;
By default this script tries to load the live reload script itself,
but if that doesn't work for some reason then you can put your app
into the easy-livereload
options.
This will add a local variable to your app
under app.locals.LRScript
.
var express = ;var app = ;var livereload = ; if app === 'development' app;
doctype htmlhtml(lang="en") head title Livereload != LRScript //- loads the livereload script
Example scripts entry in package.json
:
"scripts":