Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Grunt替换多个文件中的字符串,但略有不同_Javascript_Replace_Gruntjs - Fatal编程技术网

Javascript 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: /<!--

我需要使用Grunt在几个文件中进行类似的替换。我试图使用
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>"