{
  "name": "connect-livereload",
  "description": "connect middleware for adding the livereload script to the response",
  "version": "0.4.0",
  "author": {
    "name": "Andi Neck",
    "email": "andi.neck@intesso.com"
  },
  "contributors": [
    {
      "name": "Andi Neck",
      "email": "andi.neck@intesso.com"
    }
  ],
  "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": "*"
  },
  "readme": "connect-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[![Build Status](https://travis-ci.org/intesso/connect-livereload.png)](https://travis-ci.org/intesso/connect-livereload)\n[![NPM version](https://badge.fury.io/js/connect-livereload.png)](http://badge.fury.io/js/connect-livereload)\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 server e.g. [grunt-reload](https://github.com/webxl/grunt-reload) 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: [/\\.js$/, /\\.css$/, /\\.svg$/, /\\.ico$/, /\\.woff$/, /\\.png$/, /\\.jpg$/, /\\.jpeg$/],\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    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>)/,\n    fn: prepend\n  }, {\n    match: /<\\/html>(?![\\s\\S]*<\\/html>)/,\n    fn: prepend\n  }, {\n    match: /<\\!DOCTYPE.+>/,\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\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",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/intesso/connect-livereload/issues"
  },
  "homepage": "https://github.com/intesso/connect-livereload",
  "_id": "connect-livereload@0.4.0",
  "_shasum": "9e5bbef31e7542ef5e12cab742143bbf7636e317",
  "_from": "connect-livereload@~0.4.0",
  "_resolved": "https://registry.npmjs.org/connect-livereload/-/connect-livereload-0.4.0.tgz"
}
