Skip to content

Instantly share code, notes, and snippets.

@AlexCuse
Last active March 8, 2018 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexCuse/b2f0267c704d3ff265e446a567938aed to your computer and use it in GitHub Desktop.
Save AlexCuse/b2f0267c704d3ff265e446a567938aed to your computer and use it in GitHub Desktop.
//using https://www.npmjs.com/package/grunt-cachebuster
module.exports = function(grunt) {
grunt.initConfig({
cachebuster: {
//appears you need a sub-task
'generate-hashes': {
options: {
//basedir: 'src/EHRSim.Web'
//basedir replacement does NOT work on windows, need to handle replacement on your own
formatter: function(hashes) {
var output = '{';
for(var filename in hashes){
output += '"' + filename.replace('src/EHRSim.Web', '') + '": "' + hashes[filename] + '",';
}
output = output.replace(/(,$)/g, '');
output += '}';
return output;
}
},
files: {
'fileHashes.json': [
'src/EHRSim.Web/_static/s/**/*',
'src/EHRSim.Web/_static/c/**/*.css',
'src/EHRSim.Web/_static/i/**/*',
'src/EHRSim.Web/_static/f/**/*'
]
}
}
}
});
grunt.loadNpmTasks('grunt-cachebuster');
grunt.registerTask('default', ['foo', 'bar', 'cachebuster']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment