gulp-cdn: replace the html files require cdn domain automatically replace all the corresponding domain url, support the replacement javascript, css, img, etc. html, css , javascript code introduced using the domain name
[Chinese] (https://github.com/roninliu/gulp-cdn/blob/master/README-ZH.md "Chinese") | [English] (https://github.com/roninliu/gulp-cdn/ blob / master / README.md "English")
npm install gulp-cdn --save-dev
var gulp = require('gulp'); var cdn = require('gulp-cdn'); gulp("default", function(){ return gulp.src ("./src/*.html") .pipe(cdn({ domain:"http://localhost", cdn:"http://cdn" })) .pipe (gulp.dest("./dist/")) })
var gulp = require('gulp'); var cdn = require('gulp-cdn'); gulp("default", function(){ return gulp.src ("./src/*.html") .pipe(cdn([{ domain:"http://localhost", cdn:"http://cdn" },{ domain:"http://localhost2", cdn:"http://cdn2" }])) .pipe (gulp.dest("./dist/")) })
- Replace ago
<Script src = "http: //localhost/js/common.js"> </ script> <Link rel = "stylesheet" type = "text / css" href = "http: //localhost/index.css"> <Img src = "http: //localhost/img/share.png" alt = "">
- Replace after
<Script src = "http: //cdn/js/common.js"> </ script> <Link rel = "stylesheet" type = "text / css" href = "http: //cdn/index.css"> <Img src = "http: //cdn/img/share.png" alt = "">
see exampleexample
2016年01月04日: support array config