I'm attempting to use grunt replace in order to modify file names and append a random number to prevent caching of images, CSS, and JS files.
Here is the code I am running:
module.exports = function replace(grunt) {
var randomVersion = ((new Date()).valueOf().toString()) + (Math.floor((Math.random() * 1000000) + 1).toString());
var replace = {
options: {
variables: {
'randomVersion': randomVersion
},
overwrite: true
},
files: [{
src: './target/dist/index.html',
dest: './target/dist/index.' + randomVersion + '.html'
}]
};
console.log(randomVersion);
grunt.config.set('replace', replace);
};
However, when I run this code, all I receive is a "Destination is not defined" error. Can anyone provide any insight on this issue?
Thank you!