{"name":"connect-livereload","description":"connect middleware for adding the livereload script to the response","version":"0.4.1","author":{"name":"Andi Neck","email":"andi.neck@intesso.com"},"contributors":[{"name":"Andi Neck","email":"andi.neck@intesso.com"}],"scripts":{"test":"mocha --reporter spec"},"dependencies":{},"devDependencies":{"express":"~3.2.2","supertest":"~0.6.0","mocha":"~1.9.0"},"keywords":["connect","livereload","live-reload"],"repository":{"type":"git","url":"git://github.com/intesso/connect-livereload"},"main":"index","engines":{"node":"*"},"gitHead":"cac15c971bd8786b2564a1066b6a99bb268cba38","bugs":{"url":"https://github.com/intesso/connect-livereload/issues"},"homepage":"https://github.com/intesso/connect-livereload","_id":"connect-livereload@0.4.1","_shasum":"0f8a1a816bc9baffae4637ccea917462fe35917a","_from":".","_npmVersion":"1.4.23","_npmUser":{"name":"andineck","email":"andi.neck@intesso.com"},"maintainers":[{"name":"andineck","email":"andi.neck@intesso.com"}],"dist":{"shasum":"0f8a1a816bc9baffae4637ccea917462fe35917a","tarball":"http://registry-npm.ywwl.com/connect-livereload/download/connect-livereload-0.4.1.tgz","integrity":"sha512-y/4fDdcveHQsVXTJeAr8HHLwul5M3VI071pEaov/jiCz2HIrmZynFHuOn1CfQ8euUsdjR1Ppwsb9mgBOSij3vw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDtzC2rJAyYthQ5BqkaE1Bwxnty+mgE8tjV0iASG6U39QIgGLoMLGQsAxxqNF1yka0GDQZf8qBXT1twlDZRhRf3cfE="}],"size":4450,"noattachment":false,"key":"/connect-livereload/-/connect-livereload-0.4.1.tgz"},"directories":{},"readme":"\nconnect-livereload\n==================\nconnect middleware for adding the livereload script to the response.\nno browser plugin is needed.\nif you are happy with a browser plugin, then you don't need this middleware.\n\n[![NPM](https://nodei.co/npm/connect-livereload.png?downloads=true&downloadRank=true)](https://nodei.co/npm-dl/connect-livereload/)\n\n\n[![Build Status](https://travis-ci.org/intesso/connect-livereload.png)](https://travis-ci.org/intesso/connect-livereload)\n[![Coverage Status](https://coveralls.io/repos/intesso/connect-livereload/badge.svg)](https://coveralls.io/r/intesso/connect-livereload)\n\n\ninstall\n=======\n```bash\nnpm install connect-livereload --save-dev\n```\n\nuse\n===\nnote: if you use this middleware, you should make sure to switch off the Browser LiveReload Extension if you have it installed.\n\nthis middleware can be used with a LiveReload module e.g. [grunt-contrib-connect](https://github.com/gruntjs/grunt-contrib-connect) or [grunt-contrib-watch](https://github.com/gruntjs/grunt-contrib-watch).\n\n`connect-livereload` itself does not serve the `livereload.js` script.\n\nIn your connect or express application add this after the static and before the dynamic routes.\nIf you need liveReload on static html files, then place it before the static routes.\n`ignore` gives you the possibility to ignore certain files or url's from being handled by `connect-livereload`.\n\n## connect/express example\n```javascript\n  app.use(require('connect-livereload')({\n    port: 35729\n  }));\n```\n\nplease see the [examples](https://github.com/intesso/connect-livereload/tree/master/examples) for the app and Grunt configuration.\n\n## options\nOptions are not mandatory: `app.use(require('connect-livereload')());`\nThe Options have to be provided when the middleware is loaded:\n\ne.g.:\n```\n  app.use(require('connect-livereload')({\n    port: 35729,\n    ignore: ['.js', '.svg']\n  }));\n\n```\n\nThese are the available options with the following defaults:\n\n```javascript\n  // `ignore` and `include`: array with strings and regex expressions elements.\n  // strings: included/ignored when the url contains this string\n  // regex: any expression: e.g. starts with pattern: /^.../ ends with pattern: /...$/\n  ignore: [\n    /\\.js(\\?.*)?$/, /\\.css(\\?.*)?$/, /\\.svg(\\?.*)?$/, /\\.ico(\\?.*)?$/, /\\.woff(\\?.*)?$/,\n    /\\.png(\\?.*)?$/, /\\.jpg(\\?.*)?$/, /\\.jpeg(\\?.*)?$/, /\\.gif(\\?.*)?$/, /\\.pdf(\\?.*)?$/\n  ],\n\n  // include all urls by default\n  include: [/.*/],\n\n  // this function is used to determine if the content of `res.write` or `res.end` is html.\n  html: function (str) {\n    if (!str) return false;\n    return /<[:_-\\w\\s\\!\\/\\=\\\"\\']+>/i.test(str);\n  },\n\n  // rules are provided to find the place where the snippet should be inserted.\n  // the main problem is that on the server side it can be tricky to determine if a string will be valid html on the client.\n  // the function `fn` of the first `match` is executed like this `body.replace(rule.match, rule.fn);`\n  // the function `fn` has got the arguments `fn(w, s)` where `w` is the matches string and `s` is the snippet.\n  rules: [{\n    match: /<\\/body>(?![\\s\\S]*<\\/body>)/i,\n    fn: prepend\n  }, {\n    match: /<\\/html>(?![\\s\\S]*<\\/html>)/i,\n    fn: prepend\n  }, {\n    match: /<\\!DOCTYPE.+?>/i,\n    fn: append\n  }],\n\n  // port where the script is loaded\n  port: 35729,\n\n  // location where the script is provided (not by connect-livereload). Change this e.g. when serving livereload with a proxy.\n  src: \"http://localhost:35729/livereload.js?snipver=1\",\n\n  // Set this option to `true` to set `req.headers['accept-encoding']` to 'identity' (disabling compression)\n  disableCompression: false,\n\n  // Locations where livereload plugins are provided (not by connect-livereload).\n  // These plugins should handle being loaded before _or_ after the livereload\n  // script itself (the order is not guaranteed), like\n  // https://github.com/mixmaxhq/livereload-require-js-includes/blob/5a431793d6fdfcf93d66814ddc58338515a3254f/index.js#L40-L45\n  plugins: [\n    \"http://localhost:3001/livereload-require-js-includes/index.js\"\n  ]\n```\n\nplease see the [examples](https://github.com/intesso/connect-livereload/tree/master/examples) for the app and Grunt configuration.\n\n\n## grunt example\n\nThe following example is from an actual Gruntfile that uses [grunt-contrib-connect](https://github.com/gruntjs/grunt-contrib-connect)\n\n```javascript\nconnect: {\n  options: {\n    port: 3000,\n    hostname: 'localhost'\n  },\n  dev: {\n    options: {\n      middleware: function (connect) {\n        return [\n          require('connect-livereload')(), // <--- here\n          checkForDownload,\n          mountFolder(connect, '.tmp'),\n          mountFolder(connect, 'app')\n        ];\n      }\n    }\n  }\n}\n```\nFor use as middleware in grunt simply add the following to the **top** of your array of middleware.\n\n```javascript\n  require('connect-livereload')(),\n```\nYou can pass in options to this call if you do not want the defaults.\n\n`dev` is simply the name of the server being used with the task `grunt connect:dev`. The other items in the `middleware` array are all functions that either are of the form `function (req, res, next)` like `checkForDownload` or return that like `mountFolder(connect, 'something')`.\n\nalternative\n===========\nAn alternative would be to install the [LiveReload browser plugin](https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei).\n\n\ncredits\n=======\n* The initial middleware code was mainly extracted from: [grunt-contrib-livereload/util.js](https://github.com/gruntjs/grunt-contrib-livereload/blob/master/lib/utils.js)\n* [LiveReload Creator](http://livereload.com/)\n\ntests\n=====\nrun the tests with\n```\nmocha\n```\n\nlicense\n=======\n[MIT License](https://github.com/intesso/connect-livereload/blob/master/LICENSE)\n","publish_time":1413469651987,"_cnpm_publish_time":1413469651987,"dist-tags":{"latest":"0.6.1"}}