I have implemented the grunt-replace
task to make some content changes in the index.html file. However, I am looking for a way to avoid repeating code unnecessarily. The code snippet below is just an example of what I am trying to accomplish:
replace: {
options: {
patterns: [
{
match: /<(script.*?src=)"(?![\w/]+environment)/g,
replacement: '<$1"//<%= config.cdn[target] %>/'
}
]
},
a: {
files: [
{
src: '<%= config.path.dist.output %>/index.html',
dest: '<%= config.path.dist.output %>/index-a.html'
}
]
},
b: {
files: [
{
src: '<%= config.path.dist.output %>/index.html',
dest: '<%= config.path.dist.output %>/index-b.html'
}
]
}
}
When I trigger replace:a
, I expect the replacement pattern to be sourced from config.cdn['a']
. Similarly, when I execute replace:b
, I want the replacement pattern to come from config.cdn['b']
.
Do you think this approach is feasible?