[英]grunt-usemin with pattern is only replacing the first match
I have the following in my gruntfile: 我的gruntfile中有以下内容:
usemin: {
html: ['<%= yeoman.dist %>/**/*.html'],
css: ['<%= yeoman.dist %>/styles/**/*.css'],
js: ['<%= yeoman.dist %>/scripts/**/*.js'],
options: {
assetsDirs: ['<%= yeoman.dist %>','<%= yeoman.dist %>/styles/**/*'],
patterns: {
js: [
[/css:["']styles\/?.*\/(.*\.css)['"]/g, 'revved css resolves']
]
}
}
}
Which does what I want, given a javascript file with a reference to a revved css file, it replaces the occurrence. 给定一个javascript文件并参考已修改的css文件,该怎么办,它将替换出现的内容。 But only the first occurrence.
但是只有第一次发生。 I need this to work globally (hence the '/g' modifier. Any clues?
我需要在全球范围内使用它(因此使用'/ g'修饰符。有什么线索吗?
The input is a file that looks roughly like: 输入是一个大致如下所示的文件:
foo:{includes:{css:"styles/something.css"}},bar:{includes:{css:"styles/something.css"}}
What I end up with is (assuming 0123456 is the hash from rev): 我最终得到的是(假设0123456是来自rev的哈希):
foo:{includes:{css:"styles/0123456.something.css"}},bar:{includes:{css:"styles/something.css"}}
What I want is: 我想要的是:
foo:{includes:{css:"styles/0123456.something.css"}},bar:{includes:{css:"styles/0123456.something.css"}}
Thanks. 谢谢。
我的正则表达式太贪心了,我通过用/ /css:"styles\\/?[A-Za-z]*\\/+([A-Za-z0-9]+\\.css)"}/g
替换我的模式来解决此问题: /css:"styles\\/?[A-Za-z]*\\/+([A-Za-z0-9]+\\.css)"}/g
,现在我恢复了业务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.