1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-13 02:01:51 +00:00
tobspr_shapez.io/gulp/html.js

50 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-06-20 10:00:58 +00:00
import fs from "fs";
import gulp from "gulp";
import path from "path/posix";
2024-06-20 10:00:58 +00:00
import { buildFolder } from "./config.js";
import gulpDom from "gulp-dom";
import gulpHtmlmin from "gulp-htmlmin";
import gulpRename from "gulp-rename";
/**
* PROVIDES
*
* html
2024-06-20 10:00:58 +00:00
*/
async function buildHtml() {
2024-06-20 10:00:58 +00:00
return gulp
.src("../src/html/index.html")
.pipe(
gulpDom(
/** @this {Document} **/ function () {
const document = this;
let loadingCss = fs.readFileSync(path.join("preloader", "preloader.css")).toString();
2024-06-20 10:00:58 +00:00
const style = document.createElement("style");
style.textContent = loadingCss;
document.head.appendChild(style);
}
)
)
.pipe(
gulpHtmlmin({
caseSensitive: true,
collapseBooleanAttributes: true,
collapseInlineTagWhitespace: true,
collapseWhitespace: true,
preserveLineBreaks: true,
minifyJS: true,
minifyCSS: true,
quoteCharacter: '"',
useShortDoctype: true,
})
)
.pipe(gulpRename("index.html"))
.pipe(gulp.dest(buildFolder));
}
export default buildHtml;