browserify-cdnjs
v0.1.6
Published
Browserify transform to require libraries from jsDelivr.
Downloads
14
Maintainers
Readme
Browserify-cdn
Browserify tranform to use require() loading resources from jsDelivr.
Usage
require('jquery.cdn');
// Transforms to:
require('.cdncache/jquery/main.js');
- Recognizes if the required file name contains a .cdn extension.
- Check if the required library is already downloaded.
- Transforms the required file name to the relative path of the downloaded library.
- If isn't downloaded, checks if the required library exists on jsdelivr.com.
- Downloads the latest mainfile of the library into the .cdncache directory via this url:
https://cdn.jsdelivr.net/<library>/latest/mainfile
- Transforms the required file name to the relative path of the downloaded library.
Install
npm install browserify-cdnjs
Usage in your build script
// gulpfile.js
var cdnjs = require('browserify-cdnjs');
browserify('index.js')
.transform(cdnjs)
.bundle();