Created
May 14, 2013 16:18
-
-
Save romaricpascal/5577257 to your computer and use it in GitHub Desktop.
Sample configuration of grunt-contrib-connect and grunt-open to serve your project and open a browser tab to the appropriate URL
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) { | |
// Load Grunt tasks declared in the package.json file | |
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); | |
// Configure Grunt | |
grunt.initConfig({ | |
// grunt-contrib-connect will serve the files of the project | |
// on specified port and hostname | |
connect: { | |
all: { | |
options:{ | |
port: 9000, | |
hostname: "0.0.0.0", | |
// Prevents Grunt to close just after the task (starting the server) completes | |
// This will be removed later as `watch` will take care of that | |
keepalive: true | |
} | |
} | |
}, | |
// grunt-open will open your browser at the project's URL | |
open: { | |
all: { | |
// Gets the port from the connect configuration | |
path: 'http://localhost:<%= connect.all.options.port%>' | |
} | |
} | |
}); | |
// Creates the `server` task | |
grunt.registerTask('server',[ | |
// Open before connect because connect uses keepalive at the moment | |
// so anything after connect wouldn't run | |
'open', | |
'connect' | |
]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment