commit c21659c4fe913d98e83042c4a1babbbb44f50743
parent a829dc5c2ff088d076947870991b7a9daad146d1
Author: triesap <triesap@radroots.dev>
Date: Thu, 20 Nov 2025 13:47:55 +0000
themes: update build tooling to version the package, add a clean command, and emit consolidated and per theme stylesheet assets into an output directory
Diffstat:
3 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/themes/css/screens.css b/themes/css/screens.css
@@ -0,0 +1,13 @@
+@import "tailwindcss";
+
+@custom-variant ios1 {
+ @media (orientation: portrait) and (min-height: 750px) {
+ @slot;
+ }
+}
+
+@custom-variant ios0 {
+ @media (orientation: portrait) and (max-height: 680px) {
+ @slot;
+ }
+}
+\ No newline at end of file
diff --git a/themes/package.json b/themes/package.json
@@ -1,6 +1,6 @@
{
"name": "@radroots/themes",
- "version": "0.0.0",
+ "version": "0.0.1",
"private": false,
"license": "GPL-3.0-or-later",
"type": "module",
@@ -28,12 +28,11 @@
"build:cjs": "tsc -p tsconfig.cjs.json",
"build": "npm run build:esm && npm run build:cjs",
"prebuild": "npm run clean && npx tsx src/bin/build.ts",
- "clean": "rimraf dist css",
+ "clean": "rimraf dist",
"dev": "npm run watch",
"watch": "tsc -w"
},
"devDependencies": {
- "@radroots/dev": "*",
"@radroots/tsconfig": "*",
"tsx": "^4.20.6",
"typescript": "5.8.3"
diff --git a/themes/src/bin/build.ts b/themes/src/bin/build.ts
@@ -2,6 +2,7 @@
import fs from "node:fs";
import path from "node:path";
+import { fileURLToPath } from "node:url";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { z } from "zod";
@@ -16,12 +17,20 @@ const args_schema = z.object({
type BuildArgs = z.infer<typeof args_schema>;
-const styles_output_path = path.resolve(process.cwd(), "css/styles.css");
-const layout_output_path = path.resolve(process.cwd(), "css/layout.css");
+
+const script_dir = path.dirname(fileURLToPath(import.meta.url));
+const package_root = path.resolve(script_dir, "..", "..");
+const css_output_dir = path.resolve(package_root, "css");
+const styles_output_path = path.resolve(css_output_dir, "styles.css");
+const layout_output_path = path.resolve(css_output_dir, "layout.css");
const write_css = (file_path: string, css: string): void => {
- const dir = path.dirname(file_path);
- fs.mkdirSync(dir, { recursive: true });
+ const directory = path.dirname(file_path);
+
+ if (!fs.existsSync(directory)) {
+ fs.mkdirSync(directory, { recursive: true })
+ }
+
fs.writeFileSync(file_path, css, { encoding: "utf8" });
};
@@ -56,8 +65,8 @@ const main = (): void => {
for (const theme_key of theme_keys) {
const css = themes_css_by_preset[theme_key];
const theme_output_path = path.resolve(
- process.cwd(),
- `css/theme_${theme_key}.css`
+ css_output_dir,
+ `theme_${theme_key}.css`
);
write_css(theme_output_path, css);
}