【问题标题】:Rewrite image paths in Grunt在 Grunt 中重写图像路径
【发布时间】:2014-08-08 12:42:29
【问题描述】:

我正在寻找一个“包罗万象”的 Grunt 任务,以根据生产或开发环境重写我的 html 图像路径。我已经研究了 usemin 和 filerev - 但我无法理解到底该怎么做。

有什么我可以用来改变以下...

<img src="/img/template/banner.jpg" />

到这里:

<img src"/some-other-path-here/banner.jpg />

干杯,

【问题讨论】:

    标签: html gruntjs grunt-usemin


    【解决方案1】:

    Grunt-usemin 不是这项特定工作的任务,它旨在在一个步骤中自动执行脚本和样式的连接、缩小和加速。有几个“CDN”任务可以帮助您更改相对路径:

    【讨论】:

    • 不错。谢谢你,xiwcx! :)
    【解决方案2】:

    可以在usemin中完成

    patterns: {
                    js: [
                        [/(img\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm,'Update the JS to reference our revved images',function(match){
    return .... <-- you can replace it to whatever you want here.
    

    }

    【讨论】:

      猜你喜欢
      • 2011-05-27
      • 2013-01-25
      • 2023-03-17
      • 1970-01-01
      • 2013-07-16
      • 1970-01-01
      • 2011-09-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多