Last active
August 29, 2015 13:57
-
-
Save kurtharriger/9718839 to your computer and use it in GitHub Desktop.
Livereload starter
This file contains hidden or 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
| // For clojurescript autorecompile: https://gist.github.com/johnbintz/9498860 | |
| module.exports = function(grunt) { | |
| // Load Grunt tasks declared in the package.json file | |
| require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); | |
| // Configure Grunt | |
| grunt.initConfig({ | |
| // grunt-express will serve the files from the folders listed in `bases` | |
| // on specified `port` and `hostname` | |
| express: { | |
| all: { | |
| options: { | |
| port: 9000, | |
| hostname: "0.0.0.0", | |
| bases: ['public'], | |
| livereload: true | |
| } | |
| } | |
| }, | |
| // grunt-watch will monitor the projects files | |
| watch: { | |
| all: { | |
| // Replace with whatever file you want to trigger the update from | |
| // Either as a String for a single entry | |
| // or an Array of String for multiple entries | |
| // You can use globing patterns like `css/**/*.css` | |
| // See https://github.com/gruntjs/grunt-contrib-watch#files | |
| files: 'index.html', | |
| options: { | |
| livereload: true | |
| } | |
| } | |
| }, | |
| // grunt-open will open your browser at the project's URL | |
| open: { | |
| all: { | |
| // Gets the port from the connect configuration | |
| path: 'http://localhost:<%= express.all.options.port%>' | |
| } | |
| } | |
| }); | |
| // Creates the `server` task | |
| grunt.registerTask('server', [ | |
| 'express', | |
| 'open', | |
| 'watch' | |
| ]); | |
| }; |
This file contains hidden or 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> | |
| <body> | |
| <h1>hello</h1> | |
| <script src="http://127.0.0.1:35729/livereload.js"></script> | |
| </html> |
This file contains hidden or 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": "grunt-livereload-renewed", | |
| "version": "1.0.0", | |
| "devDependencies": { | |
| "grunt": "~0.4.1", | |
| "matchdep": "~0.1.2", | |
| "grunt-express": "~1.0.0-beta2", | |
| "grunt-contrib-watch": "~0.5.1", | |
| "grunt-open": "~0.2.1" | |
| } | |
| } |
This file contains hidden or 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
| npm init | |
| # answer prompts to create package.json | |
| npm install matchdep --save-dev | |
| npm install grunt-express --save-dev | |
| npm install grunt-contrib-watch --save-dev | |
| npm install grunt-open --save-dev | |
| # create Gruntfile.js: | |
| # http://rhumaric.com/2013/07/renewing-the-grunt-livereload-magic/ | |
| wget https://gist.githubusercontent.com/kurtharriger/9718839/raw/Gruntfile.js | |
| bower install livereload | |
| mkdir public | |
| ln -s ../bower_components bower_components | |
| wget https://gist.githubusercontent.com/kurtharriger/9718839/raw/index.html | |
| grunt server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment