DEPRECATED, use https://www.npmjs.org/package/gulp-cdn-absolute-path/
change urls in html/css/js files to cdn-based version
$ npm i gulp-cdn-ref --save-dev
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
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;
}