@n6k.io/serve 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/src/css.ts +14 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n6k.io/serve",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Serve .mdx pages with live data from n6kd or pykit",
|
|
6
6
|
"repository": "https://github.com/n6k-io/js-serve",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"@n6k.io/db": "^0.13.1",
|
|
30
30
|
"@n6k.io/runtime": "^0.1.2",
|
|
31
31
|
"@n6k.io/ui": "^0.10.6",
|
|
32
|
-
"@tailwindcss/
|
|
32
|
+
"@tailwindcss/node": "^4.3.5",
|
|
33
|
+
"@tailwindcss/oxide": "^4.3.5",
|
|
33
34
|
"@tailwindcss/typography": "^0.5.20",
|
|
34
35
|
"@tanstack/react-query": "^5.104.1",
|
|
35
36
|
"esbuild": "^0.28.2",
|
package/src/css.ts
CHANGED
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const CACHE_DIR = path.join(SERVE_NODE_MODULES, ".cache", "n6k-serve");
|
|
7
|
-
const TAILWIND = path.join(SERVE_NODE_MODULES, ".bin", "tailwindcss");
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { compile } from "@tailwindcss/node";
|
|
4
|
+
import { Scanner } from "@tailwindcss/oxide";
|
|
5
|
+
import { SRC_DIR } from "./paths";
|
|
8
6
|
|
|
9
7
|
export async function buildCss(mdxPath: string): Promise<string> {
|
|
10
|
-
mkdirSync(CACHE_DIR, { recursive: true });
|
|
11
|
-
const stem = `${process.pid}.${Bun.hash(mdxPath).toString(36)}`;
|
|
12
|
-
const input = path.join(CACHE_DIR, `${stem}.in.css`);
|
|
13
|
-
const output = path.join(CACHE_DIR, `${stem}.out.css`);
|
|
14
8
|
const base = readFileSync(path.join(SRC_DIR, "globals.css"), "utf8");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
`tailwindcss failed:\n${await new Response(proc.stderr).text()}`,
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
return readFileSync(output, "utf8");
|
|
9
|
+
const css = `${base}\n@source ${JSON.stringify(SRC_DIR)};\n@source ${JSON.stringify(path.dirname(mdxPath))};\n`;
|
|
10
|
+
const compiler = await compile(css, { base: SRC_DIR, onDependency() {} });
|
|
11
|
+
const root =
|
|
12
|
+
compiler.root === "none"
|
|
13
|
+
? []
|
|
14
|
+
: compiler.root === null
|
|
15
|
+
? [{ base: process.cwd(), pattern: "**/*", negated: false }]
|
|
16
|
+
: [{ ...compiler.root, negated: false }];
|
|
17
|
+
const sources = [...root, ...compiler.sources];
|
|
18
|
+
return compiler.build(new Scanner({ sources }).scan());
|
|
29
19
|
}
|