-
Notifications
You must be signed in to change notification settings - Fork 116
Open
Description
I was try to use gulp-posthtml, to converting URLs in XML files.
But it looks like not support self closing tags <image/>
source:

result:

This is part of my gulp configuration:
function wxml() {
return gulp.src(['src/**/*.wxml'], {
base: projRootDir,
}).pipe(plumber()).pipe(posthtml([
function postHTMLReplaceUrl (tree) {
var baseDir = path.dirname(path.relative(projRootDir, tree.options.from));
tree.walk(node => {
let src = node.attrs && node.attrs.src;
if (!src || /^(?:\w+?:)?\/\//.test(src)) {
return node;
} else if (/^\//.test(src)) {
src = src.slice(1);
} else {
src = path.join(baseDir, src);
}
if (/^images/.test(src)) {
node.attrs.src = cdnUrl(src);
}
return node;
});
}
])).pipe(gulp.dest('dist'));
}parsehex