gulp-js-url-adjuster
Find the urls in your js files, and prepend and append strings of that url.
// example gulpfile.jsvar gulp = ;var urlAdjuster = ; var options = prepend: 'http://prepend/' // prepend /foo/bar append: '?@MD5'// resolve the url and append the md5 of that file to the url root: 'test' // use the root path to resolve the file { return /^\/foo/; } // only change the absolute url start with /foo; gulp;
// jsfile.js var a = '/some/url.png';var b = '/foo/bar.jpg';var c = 'foo/bar.jpg'; { return x + y + '/foo/some/other/url.gif';}
// result js filevar a = '/some/url.png';var b = 'http://prepend/foo/bar.jpg?<jpg md5 value>';var c = 'foo/bar.jpg'; { return x + y + 'http://prepend/foo/some/other/url.gif?<gif md5 value>';}
Note
- currently only work for absolute urls
- use the same url adjuster as gulp-ex-css-url-adjuster
Todo
- Support relative url