Grunt task to modify javascript file

I have following node.js javascript file.

module.exports = function(){
    ...
    var config1 = "";
    var config2 = "";
    var config3 = "";
    ...
}

Suppose I have following grunt task.

grunt.registerTask('task1', ['...',copy]);
grunt.registerTask('task2', ['...',copy]);
grunt.registerTask('task3', ['...',copy]);

Depending on which task I am running, config1, config2, config3 varible value should change.

For example:

grunt task1

should produce

module.exports = function(){
    ...
    var config1 = "A";
    var config2 = "B";
    var config3 = "C";
    ...
}

while grunt task2

should produce

module.exports = function(){
    ...
    var config1 = "X";
    var config2 = "Y";
    var config3 = "Z";
    ...
}

Is there any grunt plugin which can do this or similar?

For simple stuff like this, I just use grunt-replace. Give it a regex to find each line and a string to replace that line with what you want the output to be. This doesn't actually parse your code though so if you later do some refactoring, the regex's will need to change.