Handling ini files with Grunt
I use grunt as a task runner for minification, uglification and concatenation of css and js.
When deploying to production, grunt build task minify’s and names the file with the timestamp, and then references this again from the server side, to alleviate any caching issues with clever browsers.
The issue was to get the timestamp from our build tools into our production code.
I wrote this Grunt ini handler to solve this very problem, below is how I’d set up a snippet of my grunt file to make use of this.
1 |
|
You can see here we have set the timestamp available within grunt, and used this to add to the filename.
The next part is using grunt-ini-handler
1 | config['ini-handler'] = { |
You are then free to include the ini within your server side code, and easily determine the latest built css and js files to include.