dbl-utils
Version:
Utilities for dbl, adba and others projects
37 lines (33 loc) • 1.05 kB
text/typescript
#! bin/ts-node
import * as path from "path";
import purgeCss from "./purge-css"; // Import the function from another file
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
const args: any = yargs(hideBin(process.argv))
.option("css", {
type: "string",
describe: "Path to the CSS file generated by the build",
demandOption: true,
})
.option("html", {
type: "string",
describe: "Path to the HTML file used for purging",
demandOption: true,
})
.help()
.alias("help", "h").argv;
// Infer output CSS file path by replacing .html with .css
console.log("css", args.css);
console.log("html", args.html);
const cssFilePath = path.resolve(args.css);
const htmlFilePath = path.resolve(args.html);
const outputCssFilePath = htmlFilePath.replace(/\.html$/, ".css");
purgeCss(cssFilePath, htmlFilePath, outputCssFilePath)
.then(() => {
console.log("DONE");
process.exit();
})
.catch((err) => {
console.error("ERROR:", err.message);
process.exit(1);
});