26 lines
725 B
JavaScript
26 lines
725 B
JavaScript
const { src, dest } = require("gulp");
|
|
const through2 = require("through2");
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
exports.default = () => {
|
|
return src("views/**/*.html")
|
|
.pipe(
|
|
through2.obj(function (file, _, cb) {
|
|
if (file.isBuffer()) {
|
|
file.contents = Buffer.from(
|
|
file.contents
|
|
.toString()
|
|
.replace(/<\$ (.*?) \$>/gm, function (m, g1) {
|
|
return fs.readFileSync(path.join(__dirname, "embeds", g1), {
|
|
encoding: "utf-8",
|
|
});
|
|
})
|
|
);
|
|
}
|
|
cb(null, file);
|
|
})
|
|
)
|
|
.pipe(src(["views/**/*", "!views/**/*.html"]))
|
|
.pipe(dest("output/"));
|
|
};
|