I need to do similar replacements in multiple files using Grunt. I am trying to use tasks string-replace, but unfortunately for each case I need to define a new task:
'string-replace': {
de: {
files: { 'public/de.html': 'src/templates/index.html' },
options: { replacements: [
{ pattern: //ig, replacement: '<script src="js/i18n/angular-locale_de-ch.js"></script>'},
{ pattern: //ig, replacement: 'de'}
]}
},
fr: {
files: { 'public/fr.html': 'src/templates/index.html' },
options: { replacements: [
{ pattern: //ig, replacement: '<script src="js/i18n/angular-locale_fr-ch.js"></script>'},
{ pattern: //ig, replacement: 'fr'}
]}
},
...
I want to define a list of files or even a template, for example. public/(*).htmland then specify the replacement
"@placeholder" -> "<script src="js/i18n/angular-locale_$1.js"></script>"
or something like that. Any suggestions?
source
share