Javascript Grunt替换多个文件中的字符串,但略有不同
我需要使用Grunt在几个文件中进行类似的替换。我试图使用Javascript Grunt替换多个文件中的字符串,但略有不同,javascript,replace,gruntjs,Javascript,Replace,Gruntjs,我需要使用Grunt在几个文件中进行类似的替换。我试图使用string replace任务,但不幸的是,对于每种情况,我都需要定义一个新任务: 'string-replace': { de: { files: { 'public/de.html': 'src/templates/index.html' }, options: { replacements: [ { pattern: /<!--
string replace
任务,但不幸的是,对于每种情况,我都需要定义一个新任务:
'string-replace': {
de: {
files: { 'public/de.html': 'src/templates/index.html' },
options: { replacements: [
{ pattern: /<!-- @locale-vendor-replacement -->/ig, replacement: '<script src="js/i18n/angular-locale_de-ch.js"></script>'},
{ pattern: /<!-- @locale-name-replacement -->/ig, replacement: 'de'}
]}
},
fr: {
files: { 'public/fr.html': 'src/templates/index.html' },
options: { replacements: [
{ pattern: /<!-- @locale-vendor-replacement -->/ig, replacement: '<script src="js/i18n/angular-locale_fr-ch.js"></script>'},
{ pattern: /<!-- @locale-name-replacement -->/ig, replacement: 'fr'}
]}
},
...
或者类似的。有什么建议吗
"@placeholder" -> "<script src="js/i18n/angular-locale_$1.js"></script>"