Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
grunt say hello

mkdir grunt-say

cd grunt-say

create file package.json, Gruntfile.js, index.html

npm install

grunt

browse http://localhost:9001

index.html file change and save

say live reload ! wow!!

'use strict';
var path = require('path');
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var folderMount = function folderMount(connect, point) {
return connect.static(path.resolve(point));
};
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
exec: {
start: {
command: 'say grunt start!'
},
startlivereload: {
command: 'say livereload start!'
},
onlivereload: {
command: 'say livereload wow!!'
}
},
connect: {
livereload: {
options: {
port: 9001,
middleware: function(connect, options) {
return [lrSnippet, folderMount(connect, '.')]
}
}
}
},
// Configuration to be run (and then tested)
regarde: {
fred: {
files: '*.html',
tasks: ['livereload', 'exec:onlivereload']
}
}
});
grunt.loadNpmTasks('grunt-regarde');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-livereload');
//grunt-exec load
grunt.loadNpmTasks('grunt-exec');
grunt.registerTask('default', ['exec:start', 'livereload-start', 'exec:startlivereload', 'connect', 'regarde']);
};
<!DOCTYPE HTML>
<html lang="ja_JP">
<head>
<meta charset="UTF-8">
</head>
<body>
Live reload now!!
</body>
</html>
{
"name": "grunt-say-hello",
"version": "0.1.0",
"Dependencies": {},
"devDependencies": {
"grunt": "~0.4.0",
"grunt-contrib-connect": "~0.1.2",
"grunt-contrib-livereload": "~0.1.1",
"grunt-regarde": "~0.1.1",
"grunt-exec": "~0.4.0"
}
}
@hendriklammers

This comment has been minimized.

Copy link

@hendriklammers hendriklammers commented Apr 24, 2013

livereload wow!! lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.