Enable live reload to work over https connections. Closes GH-197.

This commit is contained in:
Joey Baker 2013-08-28 20:54:26 -07:00 committed by Kyle Robinson Young
parent 2c84519212
commit 90e090afee
5 changed files with 53 additions and 5 deletions

View File

@ -1,4 +1,4 @@
# grunt-contrib-watch v0.5.3 [![Build Status](https://travis-ci.org/gruntjs/grunt-contrib-watch.png?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-watch)
# grunt-contrib-watch [![Build Status](https://travis-ci.org/gruntjs/grunt-contrib-watch.png?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-watch)
> Run predefined tasks whenever watched file patterns are added, changed or deleted.
@ -177,6 +177,29 @@ watch: {
},
```
<<<<<<< HEAD
=======
It's possible to get livereload working over https connections. To do this, pass an object to `livereload` with a `key` and `cert` paths specified.
Example:
```js
watch: {
css: {
files: '**/*.sass',
tasks: ['sass'],
options: {
livereload: {
port: 9000,
key: 'path/to/ssl.key',
cert: 'path/to/ssl.crt'
}
},
},
},
```
>>>>>>> Enable live reload to work over https connections
#### options.cwd
Type: `String|Object`
Default: `process.cwd()`
@ -328,7 +351,7 @@ grunt.initConfig({
Once you've started a live reload server you'll be able to access the live reload script. To enable live reload on your page, add a script tag before your closing `</body>` tag pointing to the `livereload.js` script:
```html
<script src="http://localhost:35729/livereload.js"></script>
<script src="//localhost:35729/livereload.js"></script>
```
Feel free to add this script to your template situation and toggle with some sort of `dev` flag.

View File

@ -143,7 +143,7 @@ grunt.initConfig({
Once you've started a live reload server you'll be able to access the live reload script. To enable live reload on your page, add a script tag before your closing `</body>` tag pointing to the `livereload.js` script:
```html
<script src="http://localhost:35729/livereload.js"></script>
<script src="//localhost:35729/livereload.js"></script>
```
Feel free to add this script to your template situation and toggle with some sort of `dev` flag.

View File

@ -149,6 +149,26 @@ watch: {
},
```
It's possible to get livereload working over https connections. To do this, pass an object to `livereload` with a `key` and `cert` paths specified.
Example:
```js
watch: {
css: {
files: '**/*.sass',
tasks: ['sass'],
options: {
livereload: {
port: 9000,
key: 'path/to/ssl.key',
cert: 'path/to/ssl.crt'
}
},
},
},
```
## options.cwd
Type: `String|Object`
Default: `process.cwd()`

View File

@ -28,7 +28,7 @@
},
"dependencies": {
"gaze": "~0.4.0",
"tiny-lr": "0.0.4"
"tiny-lr": "0.0.5"
},
"devDependencies": {
"grunt": "~0.4.0",

View File

@ -28,7 +28,12 @@ module.exports = function(grunt) {
if (servers[options.port]) {
this.server = servers[options.port];
} else {
this.server = tinylr();
if (options.key && options.cert) {
options.key = grunt.file.read(options.key);
options.cert = grunt.file.read(options.cert);
}
this.server = tinylr(options);
this.server.server.removeAllListeners('error');
this.server.server.on('error', function(err) {
if (err.code === 'EADDRINUSE') {