Skip to content

Instantly share code, notes, and snippets.

@Oaphi
Created October 20, 2021 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Oaphi/24a1950eecc7e2f73741cf89083ebfc3 to your computer and use it in GitHub Desktop.
Save Oaphi/24a1950eecc7e2f73741cf89083ebfc3 to your computer and use it in GitHub Desktop.
Gulpfile for creating HTML tags from single-file scripts
import GulpClient = require("gulp");
import del from "del";
import { dest, series, src, watch } from "gulp";
import { appendText, prependText } from "gulp-append-prepend";
import rename from "gulp-rename";
import ts from "gulp-typescript";
const DIST = "dist";
const SOURCE = "src/*.ts";
const project = ts.createProject("./tsconfig.json");
const clean: GulpClient.TaskFunction = () => del(DIST);
const compile: GulpClient.TaskFunction = () => {
return src(SOURCE)
.pipe(project())
.pipe(prependText("<script>"))
.pipe(appendText("</script>"))
.pipe(
rename({
extname: ".html",
})
)
.pipe(dest(DIST));
};
const watchify = () => watch(SOURCE, compile);
export default series(clean, watchify);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment