Skip to content

lisposter/gulp-cdn-ref

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-cdn-ref

DEPRECATED, use https://www.npmjs.org/package/gulp-cdn-absolute-path/

change urls in html/css/js files to cdn-based version

install

$ npm i gulp-cdn-ref --save-dev

usage

var gulp=require('gulp');
var replace=require('gulp-cdn-ref');

gulp.task('cdnref',function(){
    return gulp.src('test/fixtures/**/*')
        .pipe(replace({
            base: 'fixtures',
            cdn: 'http://lisposter.b0.upaiyun.com'
        }))
        .pipe(gulp.dest('test/expected/'));
});

and

$ gulp cdnref

See example in test

config object

var config = {
    cdn: 'http://lisposter.b0.upaiyun.com',
    base: 'assets',
    map: {
        //...
    }
}
  • cdn: your cdn service url.
  • base: the root dir of this website.

eg. here is a files tree:

project
├── style
│   └── style.css
├── assets
│   └── images
|           └── bg.png

and, here is the css:

.bg {
    background: url(../assets/bg.png) repeat;
}

so, the config may be:

var config = {
    cdn: 'http://lisposter.b0.upaiyun.com',
    base: 'project'
}

this can make your css like this:

.bg {
    background: url(http://lisposter.b0.upaiyun.com/assets/bg.png) repeat;
}

About

replace refs in .css and .js file to cdn powered links

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published