Add a banner or footer to files
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-stamp --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-stamp');
Add a banner and/or a footer to your files. This task modifies all files in
place, so dest
files are unnecessary. It's also idempotent, so you can simply
add it to the end of your build tasks and not worry about a banner or footer
being added multiple times. However, you do want to be careful about restamping
files with dynamic templates (e.g. <%= grunt.today('isoDateTime') %>
).
In your project's Gruntfile, add a section named stamp
to the data object
passed into grunt.initConfig()
.
grunt.initConfig({
stamp: {
options: {
banner: 'v<%= pkg.version %>',
footer: 'Licensed under the MIT License'
},
yourTarget: {
files: {
src: 'build/*'
}
}
}
});
Type: String
Default: none
A banner to add to your file. A line-break is inserted between the banner and the file
Type: String
Default: none
A footer to add to your file. A line-break is inserted between the footer and the file.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
- 0.2.0 Compatibility with Grunt 1.x
- 0.1.0 Initial Release