Add Custom Functionality to Existing Tasks

The public tasks exposed by the grunt-vb-build package have pre- and post- task hooks that you can redefine to add custom functionality.

For example, you can define hook tasks in Gruntfile.js to add some custom application tests before staging the application (vb-pre-stage) and some special application processing before the optimization step (vb-pre-optimize) by performing the following steps:

  1. Open Gruntfile.js.
  2. Edit the file to define the hook tasks.

    To define the hook tasks vb-pre-optimize and vb-pre-stage, your edited Gruntfile.js might be similar to the following:

    module.exports = (grunt) => {
        require('load-grunt-tasks')(grunt);
         grunt.registerTask('vb-pre-optimize', () => {
            // add custom resources or modify existing resources here
        });
         grunt.registerTask('vb-pre-stage', () => {
            // run app tests here
        });
    };