【发布时间】:2015-04-15 23:13:26
【问题描述】:
我有一个包含 id="fixedtext" 的 .html 文件,我想用 id="uniquetext" 替换所有这些 id
grunt-text-replace 只是替换它找到的第一个 id 而不会解析整个文本。
知道如何制作 grunt-text-replace https://github.com/yoniholmes/grunt-text-replace
或 咕噜替换https://www.npmjs.com/package/grunt-replace 对整个文档执行此操作,而不仅仅是第一次出现。
replace: {
dist: {
options:{
patterns:[{
match:'id="fixedtext"',
replacement: 'id="'+something[i++] +'"'
}],
files:[
{
expand: true,
src:['./source.html'],
dest:'./dest.html'
}
]
}
}
},
【问题讨论】:
-
据我研究,通过以下方法添加唯一 id 脚本字段的 id 字段是不可能的。 Grunt 任务如何缓存任务并在递归调用任务时使用它。
标签: gruntjs grunt-contrib-watch grunt-contrib-concat