替换html里面js和css引用地址
replace js'
src
and css'href
with their cdn url.
No need for
<!-- build --><!-- endbuild -->
comments.
npm install gulp-cdn-replace --save-dev
var cdn = require('gulp-cdn-replace');
gulp.task('cdn', function() {
gulp.src('./src/*.html')
.pipe(cdn({
dir: './dist',
root: {
js: 'http://cdn.example.com/somename',
css: 'http://cdn.example.com/somename',
image: 'http://cdn.example.com/somename'
},
version: {
/*
* Add '?v=1442417693439' version control which it's the timestamp of task running
*
* default false
*/
timestamp: true
}
}))
.pipe(gulp.dest('./dist'));
});
Type: Object
Type: String
Default: './dist'
The directory where you place your js and css which may be created by gulp-rev
.
Type: Object
Type: String
The CDN prefix for js files.
Type: String
The CDN prefix for css files.