I'm using grunt, connect, and livereload to serve up a test page (it's a single flat HTML page) during development, and I want to test the site on my phone. Normally I do this using web sharing—by navigating to the site using my Mac's local URL (my-imac.local
).
When I serve the page using Python's SimpleHTTPServer, this works fine. When I use grunt/connect, it's inaccessible there (though it's still accessible at localhost). How do I get connect configured to respond to these requests?
My gruntfile, for reference:
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) {
function registerRobustTasks(name, tasks) {
grunt.registerTask(name, function() {
// so we don't have stupid issues with grunt crashing
// every time a test fails...
grunt.option('force', true);
grunt.task.run(tasks);
});
}
grunt.initConfig({
pkg : grunt.file.readJSON('package.json'),
livereload : {
port : 48341
},
connect : {
livereload : {
options : {
port : 48342,
middleware : function(connect, options) {
return [lrSnippet, folderMount(connect, '.')];
}
}
}
},
regarde : {
html : {
files : ['*.html'],
tasks : ['livereload']
}
}
});
grunt.loadNpmTasks('grunt-regarde');
grunt.loadNpmTasks('grunt-contrib-livereload');
grunt.loadNpmTasks('grunt-contrib-connect');
registerRobustTasks('default', ['livereload-start', 'connect', 'regarde']);
};
Turns out it was simple: I needed a hostname : '*'
option on the connect server.