在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):kaiqigong/gulp-cdnify开源软件地址(OpenSource Url):https://github.com/kaiqigong/gulp-cdnify开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):gulp cdnifyThe gulp version of grunt-cdnify installnpm install gulp-cdnify --save-dev Usagegulp.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'
} |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论