Last active
May 11, 2020 10:11
-
-
Save aderowbotham/af9ee034f816960670fa4fd218e6a8ec to your computer and use it in GitHub Desktop.
Set cache-busing file revision using Grunt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Example using grunt-contrib-concat, but this should work with any package | |
Inject string-based timestamp into an output filename, e.g. vendor-min.ka2bct2u.js | |
*/ | |
module.exports = function(grunt) { | |
grunt.loadNpmTasks("grunt-contrib-concat"); | |
grunt.initConfig({ | |
revision: new Date().getTime().toString(36), | |
concat: { | |
options: { | |
separator: ";", | |
}, | |
vendor: { | |
src: [ | |
"node_modules/some-pkg/pgk.min.js", | |
"node_modules/some-pkg-extension/pgk-extension.min.js", | |
], | |
dest: "deploy/public/vendor/vendor-min.<%= revision %>.js", | |
} | |
} | |
}); | |
grunt.registerTask("Compile", "Concatenate vendor libraries", function(){ | |
grunt.task.run(["concat:vendor"]); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment