@kbach/react 1.0.0-beta.7 → 1.0.0-beta.8
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/README.md +52 -39
- package/dist/{chunk-P4CQSYIL.mjs → chunk-3E26VMLA.mjs} +28 -4
- package/dist/postcss-plugin.mjs +1 -1
- package/dist/vite-plugin.d.mts +37 -13
- package/dist/vite-plugin.d.ts +37 -13
- package/dist/vite-plugin.js +28 -3
- package/dist/vite-plugin.mjs +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,11 +24,10 @@ export default defineConfig({
|
|
|
24
24
|
});
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
```
|
|
27
|
+
That's it — the plugin finds or creates your `kbach.css` on its own,
|
|
28
|
+
wherever your source actually lives (`src/`, `app/`, ...; see "Where does
|
|
29
|
+
`kbach.css` go?" below if you want to know exactly where or control it).
|
|
30
|
+
Import it once from your entry point and render normally:
|
|
32
31
|
|
|
33
32
|
```tsx
|
|
34
33
|
// main.tsx
|
|
@@ -45,12 +44,25 @@ createRoot(document.getElementById('root')!).render(<App />);
|
|
|
45
44
|
</div>
|
|
46
45
|
```
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
No `initKbach()`/async step before your first render: `className` here is
|
|
48
|
+
a plain string prop, resolved entirely by the CSS `@kbach/react/vite`
|
|
49
|
+
already generated at build time, same as any other static stylesheet —
|
|
50
|
+
nothing here calls into the WASM engine at render time, so there's nothing
|
|
51
|
+
to await.
|
|
52
|
+
|
|
53
|
+
### Where does `kbach.css` go?
|
|
54
|
+
|
|
55
|
+
You don't need to think about this for the common case — skip to
|
|
56
|
+
[React Router](#react-router)/[Next.js](#nextjs) if that's what brought you
|
|
57
|
+
here. For everyone else: the plugin looks for a file already containing
|
|
58
|
+
`/* kbach:start */`/`/* kbach:end */` markers under each of your `include`
|
|
59
|
+
directories (`src`, `app`, `pages`, `components` by default) and the
|
|
60
|
+
project root, in that order, and keeps using whichever one it finds. If
|
|
61
|
+
none exists yet, it creates `<first-existing-include-dir>/kbach.css` for
|
|
62
|
+
you, markers included — you never have to hand-author that file. Pass
|
|
63
|
+
`cssFile` to `kbach()` only if you want to pin the location explicitly
|
|
64
|
+
(a path outside every `include` dir, or more than one candidate present at
|
|
65
|
+
once).
|
|
54
66
|
|
|
55
67
|
`initKbach()` (still exported from `@kbach/react`) is only needed for two
|
|
56
68
|
opt-in features that genuinely do call into the Rust/WASM engine at
|
|
@@ -88,34 +100,35 @@ createRoot(document.getElementById('root')!).render(<RouterProvider router={rout
|
|
|
88
100
|
```
|
|
89
101
|
|
|
90
102
|
**Framework mode** (`npx create-react-router@latest` — file-based routing
|
|
91
|
-
under `app/`, its own Vite plugin, SSR by default):
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
103
|
+
under `app/`, its own Vite plugin, SSR by default):
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
// vite.config.ts
|
|
107
|
+
import { reactRouter } from '@react-router/dev/vite';
|
|
108
|
+
import { kbach } from '@kbach/react/vite';
|
|
109
|
+
import { defineConfig } from 'vite';
|
|
110
|
+
|
|
111
|
+
export default defineConfig({
|
|
112
|
+
plugins: [kbach(), reactRouter()],
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Same `kbach()` call as everywhere else — its `app/`-vs-`src/` convention
|
|
117
|
+
is exactly what auto-detection (above) exists for, so there's nothing
|
|
118
|
+
React-Router-specific to configure. The one real gotcha is unrelated to
|
|
119
|
+
Kbach at all: **don't call `createRoot` yourself in `app/root.tsx`** — the
|
|
120
|
+
framework's own generated client/server entry points already do this;
|
|
121
|
+
`root.tsx` only ever *exports* a `Layout`/default component. Adding your
|
|
122
|
+
own `createRoot(...).render(...)` at that file's top level runs during SSR
|
|
123
|
+
too, where `document` doesn't exist, and crashes the build immediately.
|
|
124
|
+
`app/root.tsx` needs only:
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
import './kbach.css';
|
|
128
|
+
export default function App() {
|
|
129
|
+
return <Outlet />;
|
|
130
|
+
}
|
|
131
|
+
```
|
|
119
132
|
|
|
120
133
|
Either mode: every route's own components use `className` exactly like any
|
|
121
134
|
other component — routing has no effect on how Kbach resolves classes,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./chunk-N5HCQIBB.mjs";
|
|
8
8
|
|
|
9
9
|
// src/vite-plugin/index.ts
|
|
10
|
-
import { writeFileSync, mkdirSync, existsSync } from "fs";
|
|
10
|
+
import { readFileSync as readFileSync3, writeFileSync, mkdirSync, existsSync, statSync as statSync2 } from "fs";
|
|
11
11
|
import { join as join4, dirname } from "path";
|
|
12
12
|
import { createRequire } from "module";
|
|
13
13
|
|
|
@@ -1235,6 +1235,27 @@ function readSourceFile(path) {
|
|
|
1235
1235
|
}
|
|
1236
1236
|
|
|
1237
1237
|
// src/vite-plugin/index.ts
|
|
1238
|
+
function findMainCSSFile(root, includeDirs, explicitCssFile) {
|
|
1239
|
+
if (explicitCssFile) return join4(root, explicitCssFile);
|
|
1240
|
+
const searchDirs = [...includeDirs, "."];
|
|
1241
|
+
for (const dir of searchDirs) {
|
|
1242
|
+
const candidate = join4(root, dir, "kbach.css");
|
|
1243
|
+
if (!existsSync(candidate)) continue;
|
|
1244
|
+
try {
|
|
1245
|
+
const content = readFileSync3(candidate, "utf-8");
|
|
1246
|
+
if (content.includes(KBACH_START) && content.includes(KBACH_END)) return candidate;
|
|
1247
|
+
} catch {
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
for (const dir of includeDirs) {
|
|
1251
|
+
const full = join4(root, dir);
|
|
1252
|
+
try {
|
|
1253
|
+
if (statSync2(full).isDirectory()) return join4(full, "kbach.css");
|
|
1254
|
+
} catch {
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
return join4(root, includeDirs[0] ?? "src", "kbach.css");
|
|
1258
|
+
}
|
|
1238
1259
|
var DEFAULT_SCAN_DIRS = ["src", "app", "pages", "components"];
|
|
1239
1260
|
var CSS_SYNC_DEBOUNCE_MS = 50;
|
|
1240
1261
|
function writeFileEnsuringDir(path, content) {
|
|
@@ -1259,8 +1280,9 @@ function kbach(options = {}) {
|
|
|
1259
1280
|
let root = process.cwd();
|
|
1260
1281
|
let theme = defaultTheme;
|
|
1261
1282
|
let engine = createKbachStaticCssEngine({ root, theme, themeJson: JSON.stringify(theme), includeDirs, safelist });
|
|
1283
|
+
let mainCSSFilePath = join4(root, "src", "kbach.css");
|
|
1262
1284
|
function mainCSSFile() {
|
|
1263
|
-
return
|
|
1285
|
+
return mainCSSFilePath;
|
|
1264
1286
|
}
|
|
1265
1287
|
function classNameHintsFile() {
|
|
1266
1288
|
return join4(root, ".kbach", "kbach-classnames.d.ts");
|
|
@@ -1270,7 +1292,7 @@ function kbach(options = {}) {
|
|
|
1270
1292
|
writeFileEnsuringDir(classNameHintsFile(), dts);
|
|
1271
1293
|
}
|
|
1272
1294
|
function syncMainCSSFile(server) {
|
|
1273
|
-
const changed = writeKbachToFile(mainCSSFile(), engine.generateCSS(), readSourceFile,
|
|
1295
|
+
const changed = writeKbachToFile(mainCSSFile(), engine.generateCSS(), readSourceFile, writeFileEnsuringDir);
|
|
1274
1296
|
if (changed && server) server.watcher.emit("change", mainCSSFile());
|
|
1275
1297
|
}
|
|
1276
1298
|
let syncTimer = null;
|
|
@@ -1288,12 +1310,13 @@ function kbach(options = {}) {
|
|
|
1288
1310
|
root = resolved.root;
|
|
1289
1311
|
theme = resolveEffectiveTheme(root, options);
|
|
1290
1312
|
engine = createKbachStaticCssEngine({ root, theme, themeJson: JSON.stringify(theme), includeDirs, safelist });
|
|
1313
|
+
mainCSSFilePath = findMainCSSFile(root, includeDirs, options.cssFile);
|
|
1291
1314
|
},
|
|
1292
1315
|
buildStart() {
|
|
1293
1316
|
engine.scanProjectCssSelectorsOnce();
|
|
1294
1317
|
engine.initialScan();
|
|
1295
1318
|
engine.processSafelist();
|
|
1296
|
-
writeKbachToFile(mainCSSFile(), engine.generateCSS(), readSourceFile,
|
|
1319
|
+
writeKbachToFile(mainCSSFile(), engine.generateCSS(), readSourceFile, writeFileEnsuringDir);
|
|
1297
1320
|
writeClassNameHints();
|
|
1298
1321
|
},
|
|
1299
1322
|
// handleHotUpdate covers edits; add/unlink (create/delete) land on the
|
|
@@ -1332,6 +1355,7 @@ function kbach(options = {}) {
|
|
|
1332
1355
|
|
|
1333
1356
|
export {
|
|
1334
1357
|
createKbachStaticCssEngine,
|
|
1358
|
+
findMainCSSFile,
|
|
1335
1359
|
DEFAULT_SCAN_DIRS,
|
|
1336
1360
|
CSS_SYNC_DEBOUNCE_MS,
|
|
1337
1361
|
loadConfigFile,
|
package/dist/postcss-plugin.mjs
CHANGED
package/dist/vite-plugin.d.mts
CHANGED
|
@@ -29,16 +29,39 @@ interface KbachPluginOptions {
|
|
|
29
29
|
safelist?: string[];
|
|
30
30
|
/**
|
|
31
31
|
* Path to the `kbach:start`/`kbach:end` marker file, relative to Vite's
|
|
32
|
-
* resolved root.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
32
|
+
* resolved root. Not needed for the common case — `kbach()` auto-detects
|
|
33
|
+
* it (see `findMainCSSFile`'s own doc comment) by finding wherever you
|
|
34
|
+
* actually put the two marker comments, regardless of whether your
|
|
35
|
+
* project's source root is `src/`, `app/` (React Router v7's framework
|
|
36
|
+
* mode), or anything else in `include`. Set this explicitly only to
|
|
37
|
+
* disambiguate a genuinely unusual layout (a marker file outside every
|
|
38
|
+
* `include` directory, or more than one candidate present at once).
|
|
39
39
|
*/
|
|
40
40
|
cssFile?: string;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Finds where to read/write the `kbach:start`/`kbach:end` marker file,
|
|
44
|
+
* with no configuration required for the common case:
|
|
45
|
+
*
|
|
46
|
+
* 1. An explicit `cssFile` always wins (the one supported escape hatch).
|
|
47
|
+
* 2. Otherwise, look for a `kbach.css` already containing BOTH markers in
|
|
48
|
+
* each `include` directory (in order) and the project root itself —
|
|
49
|
+
* wherever you actually created it is where this plugin keeps using it,
|
|
50
|
+
* regardless of which framework convention (`src/`, `app/`, ...) that
|
|
51
|
+
* is. This is what makes React Router v7's framework mode (`app/
|
|
52
|
+
* kbach.css`) and a plain Vite app (`src/kbach.css`) both "just work"
|
|
53
|
+
* with the exact same `kbach()` call — no per-framework option needed.
|
|
54
|
+
* 3. No marked file exists yet (first run in a fresh project) — pick the
|
|
55
|
+
* first `include` directory that already exists as a real directory on
|
|
56
|
+
* disk, so the file this plugin is about to CREATE lands somewhere that
|
|
57
|
+
* won't need its own parent directory made up out of nothing.
|
|
58
|
+
* 4. Nothing in `include` exists yet either (a genuinely empty project,
|
|
59
|
+
* scaffolded before its first source file) — fall back to the first
|
|
60
|
+
* configured `include` entry regardless; `writeMainCSSFile` (below)
|
|
61
|
+
* creates its parent directory unconditionally, so this never crashes
|
|
62
|
+
* even here.
|
|
63
|
+
*/
|
|
64
|
+
declare function findMainCSSFile(root: string, includeDirs: string[], explicitCssFile?: string): string;
|
|
42
65
|
declare const DEFAULT_SCAN_DIRS: string[];
|
|
43
66
|
declare const CSS_SYNC_DEBOUNCE_MS = 50;
|
|
44
67
|
/**
|
|
@@ -73,11 +96,12 @@ declare function resolveEffectiveTheme(root: string, options: {
|
|
|
73
96
|
* Build-time static CSS generation for Vite — scans source files for
|
|
74
97
|
* Kbach class strings, resolves them through the same Rust engine the
|
|
75
98
|
* runtime uses (via the Node-target WASM build, see wasmNode.ts), and
|
|
76
|
-
* writes a real kbach.css.
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
99
|
+
* writes a real kbach.css. Auto-detects WHERE that file is (or should be
|
|
100
|
+
* created) via `findMainCSSFile` — no per-framework config needed for
|
|
101
|
+
* `src/`, `app/` (React Router v7's framework mode), or any other
|
|
102
|
+
* `include` convention; create a file with `/* kbach:start *\/` / `/*
|
|
103
|
+
* kbach:end *\/` markers wherever your project's source actually lives
|
|
104
|
+
* and this plugin finds it there.
|
|
81
105
|
*
|
|
82
106
|
* The actual scanning/resolution/generation logic lives in
|
|
83
107
|
* `staticCss/engine.ts`, shared with `postcss-plugin/index.ts` (Next.js/
|
|
@@ -87,4 +111,4 @@ declare function resolveEffectiveTheme(root: string, options: {
|
|
|
87
111
|
*/
|
|
88
112
|
declare function kbach(options?: KbachPluginOptions): Plugin;
|
|
89
113
|
|
|
90
|
-
export { CSS_SYNC_DEBOUNCE_MS, DEFAULT_SCAN_DIRS, type KbachPluginOptions, kbach, loadConfigFile, resolveEffectiveTheme };
|
|
114
|
+
export { CSS_SYNC_DEBOUNCE_MS, DEFAULT_SCAN_DIRS, type KbachPluginOptions, findMainCSSFile, kbach, loadConfigFile, resolveEffectiveTheme };
|
package/dist/vite-plugin.d.ts
CHANGED
|
@@ -29,16 +29,39 @@ interface KbachPluginOptions {
|
|
|
29
29
|
safelist?: string[];
|
|
30
30
|
/**
|
|
31
31
|
* Path to the `kbach:start`/`kbach:end` marker file, relative to Vite's
|
|
32
|
-
* resolved root.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
32
|
+
* resolved root. Not needed for the common case — `kbach()` auto-detects
|
|
33
|
+
* it (see `findMainCSSFile`'s own doc comment) by finding wherever you
|
|
34
|
+
* actually put the two marker comments, regardless of whether your
|
|
35
|
+
* project's source root is `src/`, `app/` (React Router v7's framework
|
|
36
|
+
* mode), or anything else in `include`. Set this explicitly only to
|
|
37
|
+
* disambiguate a genuinely unusual layout (a marker file outside every
|
|
38
|
+
* `include` directory, or more than one candidate present at once).
|
|
39
39
|
*/
|
|
40
40
|
cssFile?: string;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Finds where to read/write the `kbach:start`/`kbach:end` marker file,
|
|
44
|
+
* with no configuration required for the common case:
|
|
45
|
+
*
|
|
46
|
+
* 1. An explicit `cssFile` always wins (the one supported escape hatch).
|
|
47
|
+
* 2. Otherwise, look for a `kbach.css` already containing BOTH markers in
|
|
48
|
+
* each `include` directory (in order) and the project root itself —
|
|
49
|
+
* wherever you actually created it is where this plugin keeps using it,
|
|
50
|
+
* regardless of which framework convention (`src/`, `app/`, ...) that
|
|
51
|
+
* is. This is what makes React Router v7's framework mode (`app/
|
|
52
|
+
* kbach.css`) and a plain Vite app (`src/kbach.css`) both "just work"
|
|
53
|
+
* with the exact same `kbach()` call — no per-framework option needed.
|
|
54
|
+
* 3. No marked file exists yet (first run in a fresh project) — pick the
|
|
55
|
+
* first `include` directory that already exists as a real directory on
|
|
56
|
+
* disk, so the file this plugin is about to CREATE lands somewhere that
|
|
57
|
+
* won't need its own parent directory made up out of nothing.
|
|
58
|
+
* 4. Nothing in `include` exists yet either (a genuinely empty project,
|
|
59
|
+
* scaffolded before its first source file) — fall back to the first
|
|
60
|
+
* configured `include` entry regardless; `writeMainCSSFile` (below)
|
|
61
|
+
* creates its parent directory unconditionally, so this never crashes
|
|
62
|
+
* even here.
|
|
63
|
+
*/
|
|
64
|
+
declare function findMainCSSFile(root: string, includeDirs: string[], explicitCssFile?: string): string;
|
|
42
65
|
declare const DEFAULT_SCAN_DIRS: string[];
|
|
43
66
|
declare const CSS_SYNC_DEBOUNCE_MS = 50;
|
|
44
67
|
/**
|
|
@@ -73,11 +96,12 @@ declare function resolveEffectiveTheme(root: string, options: {
|
|
|
73
96
|
* Build-time static CSS generation for Vite — scans source files for
|
|
74
97
|
* Kbach class strings, resolves them through the same Rust engine the
|
|
75
98
|
* runtime uses (via the Node-target WASM build, see wasmNode.ts), and
|
|
76
|
-
* writes a real kbach.css.
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
99
|
+
* writes a real kbach.css. Auto-detects WHERE that file is (or should be
|
|
100
|
+
* created) via `findMainCSSFile` — no per-framework config needed for
|
|
101
|
+
* `src/`, `app/` (React Router v7's framework mode), or any other
|
|
102
|
+
* `include` convention; create a file with `/* kbach:start *\/` / `/*
|
|
103
|
+
* kbach:end *\/` markers wherever your project's source actually lives
|
|
104
|
+
* and this plugin finds it there.
|
|
81
105
|
*
|
|
82
106
|
* The actual scanning/resolution/generation logic lives in
|
|
83
107
|
* `staticCss/engine.ts`, shared with `postcss-plugin/index.ts` (Next.js/
|
|
@@ -87,4 +111,4 @@ declare function resolveEffectiveTheme(root: string, options: {
|
|
|
87
111
|
*/
|
|
88
112
|
declare function kbach(options?: KbachPluginOptions): Plugin;
|
|
89
113
|
|
|
90
|
-
export { CSS_SYNC_DEBOUNCE_MS, DEFAULT_SCAN_DIRS, type KbachPluginOptions, kbach, loadConfigFile, resolveEffectiveTheme };
|
|
114
|
+
export { CSS_SYNC_DEBOUNCE_MS, DEFAULT_SCAN_DIRS, type KbachPluginOptions, findMainCSSFile, kbach, loadConfigFile, resolveEffectiveTheme };
|
package/dist/vite-plugin.js
CHANGED
|
@@ -22,6 +22,7 @@ var vite_plugin_exports = {};
|
|
|
22
22
|
__export(vite_plugin_exports, {
|
|
23
23
|
CSS_SYNC_DEBOUNCE_MS: () => CSS_SYNC_DEBOUNCE_MS,
|
|
24
24
|
DEFAULT_SCAN_DIRS: () => DEFAULT_SCAN_DIRS,
|
|
25
|
+
findMainCSSFile: () => findMainCSSFile,
|
|
25
26
|
kbach: () => kbach,
|
|
26
27
|
loadConfigFile: () => loadConfigFile,
|
|
27
28
|
resolveEffectiveTheme: () => resolveEffectiveTheme
|
|
@@ -1754,6 +1755,27 @@ function readSourceFile(path) {
|
|
|
1754
1755
|
}
|
|
1755
1756
|
|
|
1756
1757
|
// src/vite-plugin/index.ts
|
|
1758
|
+
function findMainCSSFile(root, includeDirs, explicitCssFile) {
|
|
1759
|
+
if (explicitCssFile) return (0, import_path4.join)(root, explicitCssFile);
|
|
1760
|
+
const searchDirs = [...includeDirs, "."];
|
|
1761
|
+
for (const dir of searchDirs) {
|
|
1762
|
+
const candidate = (0, import_path4.join)(root, dir, "kbach.css");
|
|
1763
|
+
if (!(0, import_fs3.existsSync)(candidate)) continue;
|
|
1764
|
+
try {
|
|
1765
|
+
const content = (0, import_fs3.readFileSync)(candidate, "utf-8");
|
|
1766
|
+
if (content.includes(KBACH_START) && content.includes(KBACH_END)) return candidate;
|
|
1767
|
+
} catch {
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
for (const dir of includeDirs) {
|
|
1771
|
+
const full = (0, import_path4.join)(root, dir);
|
|
1772
|
+
try {
|
|
1773
|
+
if ((0, import_fs3.statSync)(full).isDirectory()) return (0, import_path4.join)(full, "kbach.css");
|
|
1774
|
+
} catch {
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
return (0, import_path4.join)(root, includeDirs[0] ?? "src", "kbach.css");
|
|
1778
|
+
}
|
|
1757
1779
|
var DEFAULT_SCAN_DIRS = ["src", "app", "pages", "components"];
|
|
1758
1780
|
var CSS_SYNC_DEBOUNCE_MS = 50;
|
|
1759
1781
|
function writeFileEnsuringDir(path, content) {
|
|
@@ -1778,8 +1800,9 @@ function kbach(options = {}) {
|
|
|
1778
1800
|
let root = process.cwd();
|
|
1779
1801
|
let theme = defaultTheme;
|
|
1780
1802
|
let engine = createKbachStaticCssEngine({ root, theme, themeJson: JSON.stringify(theme), includeDirs, safelist });
|
|
1803
|
+
let mainCSSFilePath = (0, import_path4.join)(root, "src", "kbach.css");
|
|
1781
1804
|
function mainCSSFile() {
|
|
1782
|
-
return
|
|
1805
|
+
return mainCSSFilePath;
|
|
1783
1806
|
}
|
|
1784
1807
|
function classNameHintsFile() {
|
|
1785
1808
|
return (0, import_path4.join)(root, ".kbach", "kbach-classnames.d.ts");
|
|
@@ -1789,7 +1812,7 @@ function kbach(options = {}) {
|
|
|
1789
1812
|
writeFileEnsuringDir(classNameHintsFile(), dts);
|
|
1790
1813
|
}
|
|
1791
1814
|
function syncMainCSSFile(server) {
|
|
1792
|
-
const changed = writeKbachToFile(mainCSSFile(), engine.generateCSS(), readSourceFile,
|
|
1815
|
+
const changed = writeKbachToFile(mainCSSFile(), engine.generateCSS(), readSourceFile, writeFileEnsuringDir);
|
|
1793
1816
|
if (changed && server) server.watcher.emit("change", mainCSSFile());
|
|
1794
1817
|
}
|
|
1795
1818
|
let syncTimer = null;
|
|
@@ -1807,12 +1830,13 @@ function kbach(options = {}) {
|
|
|
1807
1830
|
root = resolved.root;
|
|
1808
1831
|
theme = resolveEffectiveTheme(root, options);
|
|
1809
1832
|
engine = createKbachStaticCssEngine({ root, theme, themeJson: JSON.stringify(theme), includeDirs, safelist });
|
|
1833
|
+
mainCSSFilePath = findMainCSSFile(root, includeDirs, options.cssFile);
|
|
1810
1834
|
},
|
|
1811
1835
|
buildStart() {
|
|
1812
1836
|
engine.scanProjectCssSelectorsOnce();
|
|
1813
1837
|
engine.initialScan();
|
|
1814
1838
|
engine.processSafelist();
|
|
1815
|
-
writeKbachToFile(mainCSSFile(), engine.generateCSS(), readSourceFile,
|
|
1839
|
+
writeKbachToFile(mainCSSFile(), engine.generateCSS(), readSourceFile, writeFileEnsuringDir);
|
|
1816
1840
|
writeClassNameHints();
|
|
1817
1841
|
},
|
|
1818
1842
|
// handleHotUpdate covers edits; add/unlink (create/delete) land on the
|
|
@@ -1852,6 +1876,7 @@ function kbach(options = {}) {
|
|
|
1852
1876
|
0 && (module.exports = {
|
|
1853
1877
|
CSS_SYNC_DEBOUNCE_MS,
|
|
1854
1878
|
DEFAULT_SCAN_DIRS,
|
|
1879
|
+
findMainCSSFile,
|
|
1855
1880
|
kbach,
|
|
1856
1881
|
loadConfigFile,
|
|
1857
1882
|
resolveEffectiveTheme
|
package/dist/vite-plugin.mjs
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CSS_SYNC_DEBOUNCE_MS,
|
|
3
3
|
DEFAULT_SCAN_DIRS,
|
|
4
|
+
findMainCSSFile,
|
|
4
5
|
kbach,
|
|
5
6
|
loadConfigFile,
|
|
6
7
|
resolveEffectiveTheme
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-3E26VMLA.mjs";
|
|
8
9
|
import "./chunk-NKR3PSWO.mjs";
|
|
9
10
|
import "./chunk-N5HCQIBB.mjs";
|
|
10
11
|
export {
|
|
11
12
|
CSS_SYNC_DEBOUNCE_MS,
|
|
12
13
|
DEFAULT_SCAN_DIRS,
|
|
14
|
+
findMainCSSFile,
|
|
13
15
|
kbach,
|
|
14
16
|
loadConfigFile,
|
|
15
17
|
resolveEffectiveTheme
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kbach/react",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.8",
|
|
4
4
|
"description": "A utility-first styling engine for React, powered by a real Rust/WASM core — Tailwind CSS v4 feature parity with Kbach's own color palette.",
|
|
5
5
|
"keywords": ["css", "react", "tailwind", "utility-first", "wasm", "styling"],
|
|
6
6
|
"license": "MIT",
|