css-typed-vars 0.4.4 → 0.4.6

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 CHANGED
@@ -114,17 +114,17 @@ npx css-typed-vars --input "src/styles/**/*.{css,scss}" --output src/cssVars.ts
114
114
  npx css-typed-vars --input "src/**/*.css" --output src/cssVars.ts --exclude "**/vendor/**"
115
115
  npx css-typed-vars --input "src/**/*.css" --output src/cssVars.ts --prefix theme --naming snake
116
116
  npx css-typed-vars --input "src/**/*.css" --output src/cssVars.js # generates .js + .d.ts
117
- npx css-typed-vars --input "src/**/*.css" --output src/cssVars.ts --selector ".dark"
117
+ npx css-typed-vars --input "src/**/*.css" --output src/cssVars.ts --selector ".dark" --selector "[data-theme='dark']"
118
118
  ```
119
119
 
120
120
  | Flag | Description |
121
121
  |------|-------------|
122
- | `--input` | Glob pattern for CSS/SCSS/Less files |
122
+ | `--input` | Glob pattern for CSS/SCSS/Less files (repeatable: `--input "src/**/*.css" --input "lib/**/*.css"`) |
123
123
  | `--output` | Output file. `.ts` → TypeScript, `.js` → JavaScript + `.d.ts` alongside |
124
124
  | `--exclude` | Glob pattern for files to exclude (repeatable: `--exclude "**/a/**" --exclude "**/b/**"`) |
125
125
  | `--prefix` | Prefix for generated keys: `--prefix theme` → `themeColorPrimary` |
126
126
  | `--naming` | Key naming: `camelCase` (default), `snake`, `kebab` |
127
- | `--selector` | Extra CSS selector to scan for variables (single value; use config file for multiple) |
127
+ | `--selector` | Extra CSS selector to scan for variables (repeatable: `--selector ".dark" --selector "[data-theme='dark']"`) |
128
128
  | `--watch` | Watch for file changes and regenerate |
129
129
  | `--version`, `-v` | Print the version number and exit |
130
130
 
@@ -24,8 +24,8 @@ var unplugin_default = createUnplugin((options) => {
24
24
  configureServer(server) {
25
25
  const handle = async (file) => {
26
26
  if (!/\.(css|scss|less)$/i.test(file)) return;
27
- cachedNames = null;
28
- const names = await scanVarNames(options.input, options.exclude, options.selectors);
27
+ cachedNames = scanVarNames(options.input, options.exclude, options.selectors);
28
+ const names = await cachedNames;
29
29
  const dtsPath = getDtsPath(options);
30
30
  if (dtsPath) {
31
31
  await writeFile(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
package/dist/cli.cjs CHANGED
@@ -183,7 +183,10 @@ async function loadConfig() {
183
183
  const mod = await import((0, import_node_url.pathToFileURL)(path).href);
184
184
  return mod.default;
185
185
  }
186
- } catch {
186
+ } catch (err) {
187
+ const code = err.code;
188
+ if (code === "ENOENT" || code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND") continue;
189
+ console.warn(`css-typed-vars: failed to load config "${file}": ${err.message}`);
187
190
  }
188
191
  }
189
192
  return {};
@@ -199,7 +202,8 @@ async function main() {
199
202
  process.exit(0);
200
203
  }
201
204
  const config = await loadConfig();
202
- const input = getArg("--input") ?? config.input;
205
+ const inputArgs = getArgs("--input");
206
+ const input = inputArgs.length > 0 ? inputArgs : config.input;
203
207
  const output = getArg("--output") ?? config.output;
204
208
  const excludeArgs = getArgs("--exclude");
205
209
  const exclude = excludeArgs.length > 0 ? excludeArgs : config.exclude;
package/dist/cli.js CHANGED
@@ -38,7 +38,10 @@ async function loadConfig() {
38
38
  const mod = await import(pathToFileURL(path).href);
39
39
  return mod.default;
40
40
  }
41
- } catch {
41
+ } catch (err) {
42
+ const code = err.code;
43
+ if (code === "ENOENT" || code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND") continue;
44
+ console.warn(`css-typed-vars: failed to load config "${file}": ${err.message}`);
42
45
  }
43
46
  }
44
47
  return {};
@@ -54,7 +57,8 @@ async function main() {
54
57
  process.exit(0);
55
58
  }
56
59
  const config = await loadConfig();
57
- const input = getArg("--input") ?? config.input;
60
+ const inputArgs = getArgs("--input");
61
+ const input = inputArgs.length > 0 ? inputArgs : config.input;
58
62
  const output = getArg("--output") ?? config.output;
59
63
  const excludeArgs = getArgs("--exclude");
60
64
  const exclude = excludeArgs.length > 0 ? excludeArgs : config.exclude;
package/dist/esbuild.cjs CHANGED
@@ -139,8 +139,8 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => {
139
139
  configureServer(server) {
140
140
  const handle = async (file) => {
141
141
  if (!/\.(css|scss|less)$/i.test(file)) return;
142
- cachedNames = null;
143
- const names = await scanVarNames(options.input, options.exclude, options.selectors);
142
+ cachedNames = scanVarNames(options.input, options.exclude, options.selectors);
143
+ const names = await cachedNames;
144
144
  const dtsPath = getDtsPath(options);
145
145
  if (dtsPath) {
146
146
  await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
package/dist/esbuild.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-SWVHEM3S.js";
3
+ } from "./chunk-PYNEJIVI.js";
4
4
  import "./chunk-J7ZV6AUQ.js";
5
5
 
6
6
  // src/esbuild.ts
package/dist/rollup.cjs CHANGED
@@ -139,8 +139,8 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => {
139
139
  configureServer(server) {
140
140
  const handle = async (file) => {
141
141
  if (!/\.(css|scss|less)$/i.test(file)) return;
142
- cachedNames = null;
143
- const names = await scanVarNames(options.input, options.exclude, options.selectors);
142
+ cachedNames = scanVarNames(options.input, options.exclude, options.selectors);
143
+ const names = await cachedNames;
144
144
  const dtsPath = getDtsPath(options);
145
145
  if (dtsPath) {
146
146
  await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
package/dist/rollup.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-SWVHEM3S.js";
3
+ } from "./chunk-PYNEJIVI.js";
4
4
  import "./chunk-J7ZV6AUQ.js";
5
5
 
6
6
  // src/rollup.ts
package/dist/unplugin.cjs CHANGED
@@ -137,8 +137,8 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => {
137
137
  configureServer(server) {
138
138
  const handle = async (file) => {
139
139
  if (!/\.(css|scss|less)$/i.test(file)) return;
140
- cachedNames = null;
141
- const names = await scanVarNames(options.input, options.exclude, options.selectors);
140
+ cachedNames = scanVarNames(options.input, options.exclude, options.selectors);
141
+ const names = await cachedNames;
142
142
  const dtsPath = getDtsPath(options);
143
143
  if (dtsPath) {
144
144
  await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
package/dist/unplugin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-SWVHEM3S.js";
3
+ } from "./chunk-PYNEJIVI.js";
4
4
  import "./chunk-J7ZV6AUQ.js";
5
5
  export {
6
6
  unplugin_default as default
package/dist/vite.cjs CHANGED
@@ -139,8 +139,8 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => {
139
139
  configureServer(server) {
140
140
  const handle = async (file) => {
141
141
  if (!/\.(css|scss|less)$/i.test(file)) return;
142
- cachedNames = null;
143
- const names = await scanVarNames(options.input, options.exclude, options.selectors);
142
+ cachedNames = scanVarNames(options.input, options.exclude, options.selectors);
143
+ const names = await cachedNames;
144
144
  const dtsPath = getDtsPath(options);
145
145
  if (dtsPath) {
146
146
  await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
package/dist/vite.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-SWVHEM3S.js";
3
+ } from "./chunk-PYNEJIVI.js";
4
4
  import "./chunk-J7ZV6AUQ.js";
5
5
 
6
6
  // src/vite.ts
package/dist/webpack.cjs CHANGED
@@ -139,8 +139,8 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => {
139
139
  configureServer(server) {
140
140
  const handle = async (file) => {
141
141
  if (!/\.(css|scss|less)$/i.test(file)) return;
142
- cachedNames = null;
143
- const names = await scanVarNames(options.input, options.exclude, options.selectors);
142
+ cachedNames = scanVarNames(options.input, options.exclude, options.selectors);
143
+ const names = await cachedNames;
144
144
  const dtsPath = getDtsPath(options);
145
145
  if (dtsPath) {
146
146
  await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
package/dist/webpack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-SWVHEM3S.js";
3
+ } from "./chunk-PYNEJIVI.js";
4
4
  import "./chunk-J7ZV6AUQ.js";
5
5
 
6
6
  // src/webpack.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "css-typed-vars",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "Generate TypeScript typed constants from CSS custom properties",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",