Created
October 20, 2021 09:15
-
-
Save Oaphi/24a1950eecc7e2f73741cf89083ebfc3 to your computer and use it in GitHub Desktop.
Gulpfile for creating HTML tags from single-file scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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