Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- gulp.task("templates", () =>
- gulp.src("src/components/*.html")
- .pipe(insert.transform((content, file) => {
- const componentName = path.basename(file.path, ".html");
- const document = (new JSDOM(content)).window.document;
- const templatesTags = document.querySelectorAll("template");
- templatesTags.forEach(template => template.setAttribute("data-component", componentName));
- const templatesHTML = Array.prototype.map.call(templatesTags, tag => tag.outerHTML);
- return templatesHTML.join("");
- }))
- .pipe(concat("templates.html"))
- .pipe(gulp.dest("dist"))
- );
- gulp.task("html", () =>
- gulp.src("src/index.html")
- .pipe(replace("@@templates", () => fs.readFileSync("./dist/templates.html")))
- .pipe(gulp.dest("dist"))
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement