htmlgruntjsgrunt-usemin

Rewrite image paths in Grunt


I'm searching for a "catch-all" Grunt task to rewrite my html's image paths based on the production or dev environment. I've looked into usemin and filerev - but I'm having trouble understanding what exactly to do.

Is there anything I can use to change the following...

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

to this:

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

Cheers,


Solution

  • Grunt-usemin isn't the task for this particular job, it is meant to automate the concatenation, minification, and revving of your scripts and styles in a single step. There are several "CDN" tasks that will help you with changing relative paths: