grunt-http-server

Integration of http-server with grunt

grunt-http-server

Provides static files server integration to Grunt

 
 
npm install grunt-http-server
 

If you need to serve static files in your grunt directory you can add tasks with grunt-http-server.

Just add this task to Gruntfile:

 
 
grunt.initConfig({
 
    'http-server': {
 
        'dev': {
 
            // the server root directory 
            root: <path>,
 
            // the server port 
            // can also be written as a function, e.g. 
            // port: function() { return 8282; } 
            port: 8282,
            
 
            // the host ip address 
            // If specified to, for example, "127.0.0.1" the server will  
            // only be available on that ip. 
            // Specify "0.0.0.0" to be available everywhere 
            host: "0.0.0.0",
 
            cache: <sec>,
            showDir : true,
            autoIndex: true,
 
            // server default file extension 
            ext: "html",
 
            // run in parallel with other tasks 
            runInBackground: true|false
 
        }
 
    }
});
 
grunt.loadNpmTasks('grunt-http-server');
 
 

And run:

 
 
grunt http-server:dev
 
 

Now your static files are available in _http://127.0.0.1:8282/_.

Oscar Brito