You are on the right way. grunt-usemin will handle most of what you are looking for, but it requires other packages. To get a CSS / JS thumbnail, you need to use the grunt-contrib-cssmin combo (for CSS), grunt-contrib -uglify (for JS) combos, and while we are breaking through the cool grunt packages, I would recommend using grunt-rev to break the cache .
For your scripts to work as intended, open the useminPrepare task . This will allow you to wrap your CSS and JS files and then run tasks with them. For example, my project uses a bunch of positive effects from Bower, so I have the following in my footer.html:
<script src="./bower_components/zepto/zepto.js"></script> <script src="./bower_components/underscore/underscore-min.js"></script> <script src="./bower_components/eventEmitter/EventEmitter.js"></script> <script src="./bower_components/eventie/eventie.js"></script> <script src="./bower_components/imagesloaded/imagesloaded.js"></script> <script src="./bower_components/spin.js/spin.js"></script> <script src="./scripts/lib/zepto.touch.module.js"></script>
When launched, useminPrepare will "collect" all of this and create a configuration object that can then be used to compress / minimize. My task looks like this:
grunt.registerTask('produce',[ 'clean:main', // clean out the /dist directory if it exists 'copy', // copy files to /dist 'useminPrepare', // prepare an object of files that will be passed to concat and/or uglify 'concat', // concatenate assets 'uglify', // minify assets 'usemin', // use the minified version of these files in my html 'compass:produce', // run production version of compass 'clean:post' // cleanup junk ]);
If you really wanted to use timestamps, you could add it to the <!-- build --> comment, but I'm not quite sure if it works (I have not tested). One of the accompanying Yoman / Grint-Usemin, Addi Osmani, only recommends using grunt-rev: https://github.com/yeoman/grunt-usemin/issues/104 .
As for the last marker point, I would suggest that you want to create a tmp file, otherwise you will break the editing of the underlying HTML. If this is what you want to do, I bet you can, but I highly recommend not to.