kaiqigong / gulp-cdnify

A gulp plugin that converts local URLs to CDN ones.
17 stars 9 forks source link

how to exclude/ignore html img tag? #20

Closed xianghongai closed 6 years ago

xianghongai commented 6 years ago

img,back-end build page~

xianghongai commented 6 years ago
.pipe(cdnify({
      base: cdnHost,
      rewriter: function(url, process) {
        if (/(ico|png|jpg|gif)$/.test(url)) {
          return URL.resolve(cdnHost, url);
        } else if (/eot|svg|ttf|woff|woff2/.test(url)) {
          return '' + url;
        }
      },
      html: {
        'link[rel="icon"]': 'href',
        'link[rel="apple-touch-icon-precomposed"]': 'href',
        'meta[name="msapplication-TileImage"]': 'content'
      }
    }))