UNPKG

@unizap/unicss

Version:

Unicss: Build sleek interfaces straight from your markup. Fast, modern, utility-first CSS framework for rapid UI development.

44 lines (38 loc) 1.14 kB
#!/usr/bin/env node const path = require("path"); const fs = require("fs"); const generateCSS = require("../dist/index.js"); const args = process.argv.slice(2); let outFile = "dist/unicss.css"; let watch = false; for (let i = 0; i < args.length; i++) { if ((args[i] === "-o" || args[i] === "--output") && args[i + 1]) { outFile = args[i + 1]; i++; } if (args[i] === "-w" || args[i] === "--watch") { watch = true; } } function run() { const css = generateCSS(); const outDir = path.dirname(outFile); if (!fs.existsSync(outDir)) { fs.mkdirSync(outDir, { recursive: true }); } fs.writeFileSync(outFile, css); console.log(`CSS generated at ${outFile}`); } run(); if (watch) { const chokidar = require("chokidar"); // Watch all HTML, JS, JSX, TS, TSX, VUE files in the project, plus the config const watcher = chokidar.watch([ "**/*.{js,jsx,ts,tsx,html,vue}", // watch ALL folders, not just src/ "unicss.config.js" ], { ignoreInitial: true }); watcher.on("all", () => { console.log("Change detected. Regenerating CSS..."); run(); }); }