Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

core-cdnify

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

core-cdnify

Converts local URLs to CDN ones.

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

#gulp cdnify

This is a project forked this gulp-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[src]': 'src',
  'link[rel=stylesheet]': 'href',
  'script[src]': 'src',
  'video[poster]': 'poster',
  'source[src]': 'src'
}

Keywords

gulpplugin

FAQs

Package last updated on 29 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts