Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including grunt-hang with all npm packages installed. Try it out:

var gruntHang = require("grunt-hang")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

grunt-hang v0.1.2

Hang express/connect requests while a grunt build process is in progress

Grunt Hang

If you use grunt to build your files during development then you have probably experienced this issue. The time it takes for you to save an edited file, switch to the browser and refresh may not have been long enough for grunt to finish building. This means when you refresh you may not end up with the files you expected. Either because the files you want do not exist or are out of date.

This module provides a connect middleware that will hang connect/express requests in an application until the grunt build is complete.


$ npm install grunt-hang --save-dev


It is important that you do not use this module in production. It watches files and reads from disk syncronously.

In Express:

var hang = require('grunt-hang');


Add this line to your project's grunt.js gruntfile:

grunt.loadNpmTasks 'grunt-hang'

Then use the tasks buildStart and buildEnd when defining you build tasks eg.

grunt.registerTask("default", 'buildStart clean lint test buildEnd');



RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free