Created
September 16, 2015 08:14
-
-
Save weralwolf/d845198769d7a2b22a22 to your computer and use it in GitHub Desktop.
Simple example of server with live reload for Grunt.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
require("load-grunt-tasks")(grunt); // npm install --save-dev load-grunt-tasks | |
grunt.initConfig({ | |
watch: { | |
statics: { | |
files: ['index.html'], | |
options: { | |
livereload: true, | |
}, | |
}, | |
}, | |
connect: { | |
server: { | |
options: { | |
useAvailablePort: true, | |
hostname: '*', | |
open: true, | |
livereload: true, | |
}, | |
}, | |
}, | |
}); | |
grunt.registerTask('serve', ['connect:server', 'watch']); | |
grunt.registerTask('default', ['serve']); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Simplest example of grunt server with reload</title> | |
</head> | |
<body> | |
<p> | |
Here's nothing, but with <code>grunt serve</code> you'll create a small server with live reload. | |
To add more files affecting reload extend <code>watch</code> section of <code>Gruntfile.json</code> | |
as exampled. | |
</p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "simple-server", | |
"version": "1.0.0", | |
"description": "Simplest grunt server example with live-reload.", | |
"main": "index.html", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": ["grunt", "live-reload"], | |
"author": "Anatolii Koval", | |
"license": "ISC", | |
"dependencies": {}, | |
"devDependencies": { | |
"grunt": "^0.4.5", | |
"grunt-contrib-connect": "^0.11.2", | |
"grunt-contrib-watch": "^0.6.1", | |
"load-grunt-tasks": "^3.2.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment