grunt-hapify
Start a hapi server
Includes console logging plugin through good-console.
Note that this server only runs as long as grunt is running. Once grunt's tasks have completed, the web server stops. This behavior can be changed with the keepalive option.
This task was designed to be used in conjunction with another task that is run immediately afterwards, like the grunt-contrib-watch plugin watch
task.
You can run this task with the grunt hapify
command.
Install
$ npm install --save-dev grunt-hapify
Usage
grunt; grunt; grunt;
Defaults
Default plugins are Good, Visionary, Blipp, and Inert.
This gives us routes logging support, template rendering support, and static file serving.
Default plugin configs can be overwritten my passing: { nameOfDefaultPlugin: { ..config } }
For example: { visionary: { path: './assets' } }
Options
keepalive
Type: Boolean
Default: false
Keep the server alive indefinitely. Note that if this option is enabled, any tasks specified after this task will never run. By default, once grunt's tasks have completed, the web server stops. This option changes that behavior.
server
Type: Object
Default: { debug: false }
Options used to initialize the hapi serve (new Hapi.Server(<server>)
).
See hapi server options for more info
connection
Type: Object
Default: { port: 9090, routes: { cors: true } }
Options used to start a connection (server.connection(<connection>)
).
See hapi connection options for more info.
routes
Type: Array
Default: { path: '/', method: 'get', handler: function (req, rep) { return rep('Grunt Hapify'); } }
Server routes to load on the server (server.route(<routes>)
).
See hapi routes for more info.
plugins
Type: Array
Default: Good Plugin
Hapi plugins to load on the server (server.register(<plugins>)
).
See hapi plugins for more info.
Todo
- Support Livereload
Done
- Serve static files using inert
- Render templates using vision
Contributing
- Include 100% test coverage.
- Follow the Hapi coding conventions
- Submit an issue first for significant changes.