gulp-html-url-prefix-custom
a plugin of gulp for prefix url
install
npm install gulp-html-url-prefix-custom
options
- options - type:
object
- prefix:
string
, default
- prefix:
urlPrefix({
prefix: '//cdn.xxx.com'
})
example
index.html
<!DOCTYPE html>
<html>
<head>
<link href="./css/example.css" />
</head>
<body>
<img src="./example.jpg" />
<script type="text/javascript" src="./js/example.js"></script>
</body>
</html>
gulpfile.js
var urlPrefix = require('gulp-html-url-prefix-custom'),
gulp = require('gulp');
gulp.task('url', function() {
gulp.src(['index.html'])
.pipe(urlPrefix({
prefix: '//cdn.xxx.com';
attrdata: ["img:src", "img:srcset", "img:s-src", "img:data-src", "script:src", "link:href"] //自定义标签属性
}))
.pipe(gulp.dest('./'));
});
and the result is:
<!DOCTYPE html>
<html>
<head>
<link href="//cdn.xxx.com/css/example.css" />
</head>
<body>
<img src="//cdn.xxx.com/example.jpg" />
<script type="text/javascript" src="//cdn.xxx.com/js/example.js"></script>
</body>
</html>
License
MIT