gulp-cdnify
Converts local URLs to CDN ones.
Last updated 2 years ago by cagegong .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install gulp-cdnify 
SYNC missed versions from official npm registry.

gulp cdnify

The gulp version of grunt-cdnify

install

npm install gulp-cdnify --save-dev

Usage

gulp.task('cdnify', function () {

  var cdnify = require('gulp-cdnify');

  return gulp.src([
    'dist/**/*.{css,html}'
  ])
    .pipe(cdnify({
      base: 'http://pathto/your/cdn/'
    }))
    .pipe(gulp.dest('dist/'))
});

For those who want to rewrite the url with their own specific rules.

pipe($.cdnify({
  rewriter: function(url, process) {
    if (/eot]ttf|woff|woff2/.test(url)) {
      return 'http://myfontcdn.com/' + url;
    } else if (/(png|jpg|gif)$/.test(url)) {
      return 'http://myimagecdn.com/' + url;
    } else {
      return process(url);
    }
  }
}));

If you want to read custom source (Eg. favicon)

pipe($.cdnify({
  html: {
    'link[rel="shortcut icon"]': 'href',
    'link[rel="apple-touch-icon-precomposed"]': 'href'
  }
}));

Default sources:

sources = {
  'img[data-src]': 'data-src',
  'img[src]': 'src',
  'link[rel="apple-touch-icon"]': 'href',
  'link[rel="icon"]': 'href',
  'link[rel="shortcut icon"]': 'href',
  'link[rel="stylesheet"]': 'href',
  'script[src]': 'src',
  'source[src]': 'src',
  'video[poster]': 'poster'
}

Current Tags

  • 1.0.8                                ...           latest (2 years ago)

9 Versions

  • 1.0.8                                ...           2 years ago
  • 1.0.7                                ...           4 years ago
  • 1.0.6                                ...           4 years ago
  • 1.0.5                                ...           5 years ago
  • 1.0.4                                ...           5 years ago
  • 1.0.3-pre                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 6
This Month 42
Last Day 1
Last Week 7
Last Month 27
Dependencies (5)
Dev Dependencies (1)

Copyright 2014 - 2016 © taobao.org |