grunt-directives

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-directives --save-dev

One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

In this example, running grunt directives:dist (or grunt directives because directives is a [multi task][]) will process the specified source files (in order), joining files with ;, process them to look for @include directives and writing the output to dist/built.js.

In this example, running grunt directives:dist will first concatenate the source files, process them to look for @include directives and concatenate a newly-generated banner comment at the top, writing the output to dist/built.js.

This generated banner will be the contents of the banner template string interpolated with the config object. In this case, those properties are the values imported from the package.json file (which are available via the pkg config property) plus today's date.

Note: you don't have to use an external JSON file. It's also valid to create the pkg object inline in the config. That being said, if you already have a JSON file, you might as well reference it.