I'm trying to remove all line breaks in an HTML file using gulp-regex-replace
. I'm trying the regular expressions from here. None of them work.
let replace = require('gulp-regex-replace');
gulp.task("strip", function () {
return (
gulp
.src("./*.html")
.pipe(replace({regex:/\r?\n|\r/g, replace:''}))
.pipe(gulp.dest("./dist/"))
);
});
I also tried /[\r\n] /gm
with no luck.
Trying other regular expressions works, but line breaks don't budge. I'm using OS X with VSCode.
CodePudding user response:
I would switch to gulp-replace. gulp-regex-replace
was last published 8 years ago and probably doesn't work well with gulp4. .
I tested this with gulp-replace
and it worked to remove newlines.
const replace = require('gulp-replace');
gulp.task("strip", function () {
return (
gulp
.src("./*.html")
.pipe(replace(/\r?\n/g, '')) // simpler syntax too
.pipe(gulp.dest("dist")) // this is probably enough for you
);
});