const { readdirSync, readFileSync, writeFileSync } = require("fs"); const { minify } = require("html-minifier-terser"); const { extname, join } = require("path"); const { execSync } = require("child_process"); const OUT_PATH = "out"; const HTML_MINIFIER_CONFIG = { collapseBooleanAttributes: true, collapseInlineTagWhitespace: true, collapseWhitespace: true, decodeEntities: true, includeAutoGeneratedTags: false, minifyJS: true, minifyURLs: true, processConditionalComments: true, processScripts: ["text/html"], removeAttributeQuotes: true, removeComments: true, removeEmptyAttributes: true, removeOptionalTags: true, removeRedundantAttributes: true, removeScriptTypeAttributes: true, removeStyleLinkTypeAttributes: true, sortAttributes: true, sortClassName: true, trimCustomFragments: true, useShortDoctype: true, }; let commit = process.env.npm_package_gitHead?.slice(0, 6); if (!commit) { try { commit = execSync("git rev-parse --short HEAD", { cwd: __dirname }) .toString() .trim(); } catch { commit = new Date().toISOString().slice(0, 10); } } const CODE_REPLACE_FUNCTIONS = [ (html) => html.replace(/