abtmtr-v4/gulpfile.js

27 lines
703 B
JavaScript
Raw Normal View History

2023-11-23 08:53:28 +00:00
const { src, dest } = require("gulp");
const through2 = require("through2");
const fs = require("fs");
const path = require("path");
exports.default = () => {
2023-11-23 18:05:19 +00:00
return src("views/**/*.html")
2023-11-23 08:53:28 +00:00
.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);
})
)
2023-11-23 18:02:53 +00:00
.pipe(src("views/**/*"))
2023-11-23 08:53:28 +00:00
.pipe(dest("output/"));
};