Skip to content

Instantly share code, notes, and snippets.

@himanshurajora
Created May 7, 2023 18:19
Show Gist options
  • Save himanshurajora/af3e6e91c908589fbf9e4251f843af26 to your computer and use it in GitHub Desktop.
Save himanshurajora/af3e6e91c908589fbf9e4251f843af26 to your computer and use it in GitHub Desktop.
GulpJs html live compile and host
const gulp = require("gulp");
const comments = require("gulp-header-comment");
const fileInclude = require("gulp-file-include");
const bs = require("browser-sync");
const path = {
src: {
html: "src/**/*.html",
},
};
gulp.task("html", () => {
return gulp
.src(path.src.html)
.pipe(
fileInclude({
basepath: "src/partial",
})
)
.pipe(comments(`Website by Vedik Devs`))
.pipe(gulp.dest("./output"));
});
gulp.task("watch:html", function () {
gulp.watch(["src/**/*.html", "src/**/*.html"], gulp.series("html"));
});
gulp.task(
"default",
gulp.series(
"html",
gulp.parallel("watch:html", function () {
bs.init({
server: "output/",
});
})
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment