From 44304da767f2b2a949fa9a34e4dbfc27d5044721 Mon Sep 17 00:00:00 2001 From: Imants Date: Thu, 21 Nov 2024 22:59:01 +0200 Subject: [PATCH] feat: init wcmw.bar --- package.json | 2 +- scripts/css.mjs | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 scripts/css.mjs diff --git a/package.json b/package.json index 251e7d3..1e931cc 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "dev": "vite", - "build": "vite build" + "build": "vite build && node scripts/css.mjs" }, "keywords": [], "author": "", diff --git a/scripts/css.mjs b/scripts/css.mjs new file mode 100644 index 0000000..42267d9 --- /dev/null +++ b/scripts/css.mjs @@ -0,0 +1,22 @@ +import { glob } from "glob" +import fs from "fs" +import path from "path" + +// Define the build directory and target output +const buildDir = "_site/assets" +const targetFileName = "styles.css" +const targetPath = path.join(buildDir, targetFileName) + +// Find the generated CSS file (assuming there's only one CSS file) +const cssFiles = glob.sync(`${buildDir}/*.css`) + +if (cssFiles.length === 0) { + console.error("No CSS file found in the build directory.") + process.exit(0) // Exit the script +} + +const sourceFile = cssFiles[0] // Take the first CSS file found + +// Copy and rename the CSS file +fs.copyFileSync(sourceFile, targetPath) +console.log(`CSS file '${sourceFile}' copied to: '${targetPath}'`)