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 +3 -3
- package/dist/{chunk-SWVHEM3S.js → chunk-PYNEJIVI.js} +2 -2
- package/dist/cli.cjs +6 -2
- package/dist/cli.js +6 -2
- package/dist/esbuild.cjs +2 -2
- package/dist/esbuild.js +1 -1
- package/dist/rollup.cjs +2 -2
- package/dist/rollup.js +1 -1
- package/dist/unplugin.cjs +2 -2
- package/dist/unplugin.js +1 -1
- package/dist/vite.cjs +2 -2
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +2 -2
- package/dist/webpack.js +1 -1
- package/package.json +1 -1
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 (
|
|
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 =
|
|
28
|
-
const names = await
|
|
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
|
|
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
|
|
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 =
|
|
143
|
-
const names = await
|
|
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
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 =
|
|
143
|
-
const names = await
|
|
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
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 =
|
|
141
|
-
const names = await
|
|
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
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 =
|
|
143
|
-
const names = await
|
|
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
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 =
|
|
143
|
-
const names = await
|
|
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