|
1 | | -import { execSync } from "child_process"; |
2 | | -import fs from "fs"; |
| 1 | +const { execSync } = require("child_process"); |
| 2 | +const fs = require("fs"); |
3 | 3 |
|
4 | 4 | console.log("🧩 Building JKCSS 7.0.0..."); |
5 | 5 |
|
6 | | -// Ensure dist exists |
7 | | -if (!fs.existsSync("dist")) fs.mkdirSync("dist"); |
| 6 | +// Ensure dist directory exists |
| 7 | +if (!fs.existsSync("dist")) fs.mkdirSync("dist", { recursive: true }); |
8 | 8 |
|
9 | | -// Build normal (expanded) version |
10 | | -execSync("sass src/jkcss.scss dist/jkcss.css --no-source-map --style=expanded", { stdio: "inherit" }); |
| 9 | +// Helper function to safely run commands |
| 10 | +function run(command) { |
| 11 | + try { |
| 12 | + execSync(command, { stdio: "inherit" }); |
| 13 | + } catch (err) { |
| 14 | + console.error("❌ Build failed!"); |
| 15 | + console.error(err.message); |
| 16 | + process.exit(1); |
| 17 | + } |
| 18 | +} |
11 | 19 |
|
12 | | -// Build minified version |
13 | | -execSync("sass src/jkcss.scss dist/jkcss.min.css --no-source-map --style=compressed", { stdio: "inherit" }); |
| 20 | +// Detect sass command: try local (npx) first, fallback to global |
| 21 | +const sassCmd = "npx sass"; |
14 | 22 |
|
15 | | -console.log("✅ Build complete!"); |
| 23 | +console.log("⚙️ Compiling expanded version..."); |
| 24 | +run(`${sassCmd} src/jkcss.scss dist/jkcss.css --no-source-map --style=expanded`); |
| 25 | + |
| 26 | +console.log("⚙️ Compiling minified version..."); |
| 27 | +run(`${sassCmd} src/jkcss.scss dist/jkcss.min.css --no-source-map --style=compressed`); |
| 28 | + |
| 29 | +console.log("\n✅ Build complete!"); |
16 | 30 | console.log("📦 Generated: dist/jkcss.css"); |
17 | 31 | console.log("📦 Generated: dist/jkcss.min.css"); |
0 commit comments