css-typed-vars 0.3.0 → 0.4.0
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 +9 -1
- package/dist/{chunk-4VL6W5GO.js → chunk-B6LVS5G7.js} +11 -7
- package/dist/{chunk-B57NHMQD.js → chunk-PKKMLIWX.js} +4 -4
- package/dist/{chunk-3XKCOLZL.js → chunk-Z7K77FZI.js} +5 -2
- package/dist/cli.cjs +34 -15
- package/dist/cli.js +17 -9
- package/dist/esbuild.cjs +14 -10
- package/dist/esbuild.js +2 -2
- package/dist/index.cjs +15 -8
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -2
- package/dist/rollup.cjs +14 -10
- package/dist/rollup.js +2 -2
- package/dist/unplugin.cjs +14 -10
- package/dist/unplugin.d.cts +1 -0
- package/dist/unplugin.d.ts +1 -0
- package/dist/unplugin.js +2 -2
- package/dist/vite.cjs +14 -10
- package/dist/vite.js +2 -2
- package/dist/webpack.cjs +14 -10
- package/dist/webpack.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
<img src="https://repository-images.githubusercontent.com/1204912196/ef5412c5-0846-4b94-bf5d-811202144eb9" alt="css-typed-vars" />
|
|
2
|
+
|
|
1
3
|
<h1>css-typed-vars</h1>
|
|
2
4
|
<p>Generate TypeScript typed constants from CSS custom properties</p>
|
|
3
5
|
|
|
@@ -112,6 +114,7 @@ npx css-typed-vars --input "src/styles/**/*.{css,scss}" --output src/cssVars.ts
|
|
|
112
114
|
npx css-typed-vars --input "src/**/*.css" --output src/cssVars.ts --exclude "**/vendor/**"
|
|
113
115
|
npx css-typed-vars --input "src/**/*.css" --output src/cssVars.ts --prefix theme --naming snake
|
|
114
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"
|
|
115
118
|
```
|
|
116
119
|
|
|
117
120
|
| Flag | Description |
|
|
@@ -121,7 +124,9 @@ npx css-typed-vars --input "src/**/*.css" --output src/cssVars.js # generates .
|
|
|
121
124
|
| `--exclude` | Glob pattern for files to exclude (single value; use config file for multiple) |
|
|
122
125
|
| `--prefix` | Prefix for generated keys: `--prefix theme` → `themeColorPrimary` |
|
|
123
126
|
| `--naming` | Key naming: `camelCase` (default), `snake`, `kebab` |
|
|
127
|
+
| `--selector` | Extra CSS selector to scan for variables (single value; use config file for multiple) |
|
|
124
128
|
| `--watch` | Watch for file changes and regenerate |
|
|
129
|
+
| `--version`, `-v` | Print the version number and exit |
|
|
125
130
|
|
|
126
131
|
CLI flags override values from the config file.
|
|
127
132
|
|
|
@@ -143,6 +148,7 @@ export default {
|
|
|
143
148
|
exclude: ['**/vendor/**', '**/node_modules/**'],
|
|
144
149
|
prefix: 'theme',
|
|
145
150
|
naming: 'snake', // 'camelCase' | 'snake' | 'kebab'
|
|
151
|
+
selectors: ['.dark', '[data-theme="dark"]'],
|
|
146
152
|
};
|
|
147
153
|
```
|
|
148
154
|
|
|
@@ -240,6 +246,7 @@ Turbopack does not yet have a public plugin API for virtual modules. Use the CLI
|
|
|
240
246
|
| `exclude` | `string \| string[]` | — | Glob pattern(s) for files to exclude |
|
|
241
247
|
| `prefix` | `string` | — | Prefix for generated keys: `'theme'` → `themeColorPrimary` |
|
|
242
248
|
| `naming` | `'camelCase' \| 'snake' \| 'kebab'` | `'camelCase'` | Key naming convention |
|
|
249
|
+
| `selectors` | `string[]` | — | Extra CSS selectors to scan, e.g. `['.dark', '[data-theme="dark"]']` |
|
|
243
250
|
| `dts` | `string \| false` | inside `node_modules` | Path to write type declarations. `false` to skip |
|
|
244
251
|
|
|
245
252
|
---
|
|
@@ -296,6 +303,7 @@ await generate({
|
|
|
296
303
|
exclude: ['**/vendor/**'],
|
|
297
304
|
prefix: 'theme',
|
|
298
305
|
naming: 'snake', // 'camelCase' | 'snake' | 'kebab'
|
|
306
|
+
selectors: ['.dark', '[data-theme="dark"]'],
|
|
299
307
|
});
|
|
300
308
|
```
|
|
301
309
|
|
|
@@ -313,7 +321,7 @@ import { parseVarNames, generateCode, scanVarNames } from 'css-typed-vars';
|
|
|
313
321
|
| SCSS | `.scss` |
|
|
314
322
|
| Less | `.less` |
|
|
315
323
|
|
|
316
|
-
|
|
324
|
+
By default, variables are scanned from `:root {}` blocks (including attribute selectors like `:root[data-theme="dark"]`). Use the `selectors` option to also pick up variables from other selectors such as `.dark` or `[data-theme="dark"]`.
|
|
317
325
|
|
|
318
326
|
## Contributing
|
|
319
327
|
|
|
@@ -6,13 +6,17 @@ var getDirname = () => path.dirname(getFilename());
|
|
|
6
6
|
var __dirname = /* @__PURE__ */ getDirname();
|
|
7
7
|
|
|
8
8
|
// src/parser.ts
|
|
9
|
-
function parseVarNames(css) {
|
|
9
|
+
function parseVarNames(css, selectors) {
|
|
10
10
|
const stripped = css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "");
|
|
11
11
|
const names = /* @__PURE__ */ new Set();
|
|
12
|
-
const
|
|
13
|
-
for (const
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const allSelectors = [":root", ...selectors ?? []];
|
|
13
|
+
for (const sel of allSelectors) {
|
|
14
|
+
const escaped = sel.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
15
|
+
const regex = new RegExp(`${escaped}[^{]*\\{([^}]*)\\}`, "g");
|
|
16
|
+
for (const match of stripped.matchAll(regex)) {
|
|
17
|
+
for (const prop of match[1].matchAll(/--[\w-]+(?=\s*:)/g)) {
|
|
18
|
+
names.add(prop[0]);
|
|
19
|
+
}
|
|
16
20
|
}
|
|
17
21
|
}
|
|
18
22
|
return [...names];
|
|
@@ -21,7 +25,7 @@ function parseVarNames(css) {
|
|
|
21
25
|
// src/scanner.ts
|
|
22
26
|
import { readFile } from "fs/promises";
|
|
23
27
|
import fg from "fast-glob";
|
|
24
|
-
async function scanVarNames(patterns, exclude) {
|
|
28
|
+
async function scanVarNames(patterns, exclude, selectors) {
|
|
25
29
|
const normalized = (Array.isArray(patterns) ? patterns : [patterns]).map(
|
|
26
30
|
(p) => p.replace(/\\/g, "/")
|
|
27
31
|
);
|
|
@@ -31,7 +35,7 @@ async function scanVarNames(patterns, exclude) {
|
|
|
31
35
|
await Promise.all(
|
|
32
36
|
files.map(async (file) => {
|
|
33
37
|
const css = await readFile(file, "utf8");
|
|
34
|
-
for (const name of parseVarNames(css)) {
|
|
38
|
+
for (const name of parseVarNames(css, selectors)) {
|
|
35
39
|
all.add(name);
|
|
36
40
|
}
|
|
37
41
|
})
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
generateDeclaration,
|
|
4
4
|
generateJs,
|
|
5
5
|
scanVarNames
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-B6LVS5G7.js";
|
|
7
7
|
|
|
8
8
|
// src/unplugin.ts
|
|
9
9
|
import { createUnplugin } from "unplugin";
|
|
@@ -22,7 +22,7 @@ var unplugin_default = createUnplugin((options) => ({
|
|
|
22
22
|
configureServer(server) {
|
|
23
23
|
server.watcher.on("change", async (file) => {
|
|
24
24
|
if (!/\.(css|scss|less)$/i.test(file)) return;
|
|
25
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
25
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
26
26
|
const dtsPath = getDtsPath(options);
|
|
27
27
|
if (dtsPath) {
|
|
28
28
|
await writeFile(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
@@ -38,7 +38,7 @@ var unplugin_default = createUnplugin((options) => ({
|
|
|
38
38
|
async buildStart() {
|
|
39
39
|
const dtsPath = getDtsPath(options);
|
|
40
40
|
if (!dtsPath) return;
|
|
41
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
41
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
42
42
|
await writeFile(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
43
43
|
},
|
|
44
44
|
resolveId(id) {
|
|
@@ -46,7 +46,7 @@ var unplugin_default = createUnplugin((options) => ({
|
|
|
46
46
|
},
|
|
47
47
|
async load(id) {
|
|
48
48
|
if (id === RESOLVED_ID) {
|
|
49
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
49
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
50
50
|
return generateJs(names, options.prefix, options.naming);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -3,13 +3,16 @@ import {
|
|
|
3
3
|
generateDeclaration,
|
|
4
4
|
generateJs,
|
|
5
5
|
scanVarNames
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-B6LVS5G7.js";
|
|
7
7
|
|
|
8
8
|
// src/index.ts
|
|
9
9
|
import { writeFile, mkdir } from "fs/promises";
|
|
10
10
|
import { dirname, resolve } from "path";
|
|
11
11
|
async function generate(options) {
|
|
12
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
12
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
13
|
+
if (names.length === 0) {
|
|
14
|
+
console.warn("css-typed-vars: no CSS custom properties found.");
|
|
15
|
+
}
|
|
13
16
|
const outPath = resolve(options.output);
|
|
14
17
|
await mkdir(dirname(outPath), { recursive: true });
|
|
15
18
|
if (options.output.endsWith(".js")) {
|
package/dist/cli.cjs
CHANGED
|
@@ -23,6 +23,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
mod
|
|
24
24
|
));
|
|
25
25
|
|
|
26
|
+
// node_modules/tsup/assets/cjs_shims.js
|
|
27
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
28
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
29
|
+
|
|
26
30
|
// src/cli.ts
|
|
27
31
|
var import_promises3 = require("fs/promises");
|
|
28
32
|
var import_node_path2 = require("path");
|
|
@@ -38,20 +42,24 @@ var import_promises = require("fs/promises");
|
|
|
38
42
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
39
43
|
|
|
40
44
|
// src/parser.ts
|
|
41
|
-
function parseVarNames(css) {
|
|
45
|
+
function parseVarNames(css, selectors) {
|
|
42
46
|
const stripped = css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "");
|
|
43
47
|
const names = /* @__PURE__ */ new Set();
|
|
44
|
-
const
|
|
45
|
-
for (const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
const allSelectors = [":root", ...selectors ?? []];
|
|
49
|
+
for (const sel of allSelectors) {
|
|
50
|
+
const escaped = sel.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
51
|
+
const regex = new RegExp(`${escaped}[^{]*\\{([^}]*)\\}`, "g");
|
|
52
|
+
for (const match of stripped.matchAll(regex)) {
|
|
53
|
+
for (const prop of match[1].matchAll(/--[\w-]+(?=\s*:)/g)) {
|
|
54
|
+
names.add(prop[0]);
|
|
55
|
+
}
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
58
|
return [...names];
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
// src/scanner.ts
|
|
54
|
-
async function scanVarNames(patterns, exclude) {
|
|
62
|
+
async function scanVarNames(patterns, exclude, selectors) {
|
|
55
63
|
const normalized = (Array.isArray(patterns) ? patterns : [patterns]).map(
|
|
56
64
|
(p) => p.replace(/\\/g, "/")
|
|
57
65
|
);
|
|
@@ -61,7 +69,7 @@ async function scanVarNames(patterns, exclude) {
|
|
|
61
69
|
await Promise.all(
|
|
62
70
|
files.map(async (file) => {
|
|
63
71
|
const css = await (0, import_promises.readFile)(file, "utf8");
|
|
64
|
-
for (const name of parseVarNames(css)) {
|
|
72
|
+
for (const name of parseVarNames(css, selectors)) {
|
|
65
73
|
all.add(name);
|
|
66
74
|
}
|
|
67
75
|
})
|
|
@@ -130,7 +138,10 @@ function generateDeclaration(varNames, prefix, naming) {
|
|
|
130
138
|
|
|
131
139
|
// src/index.ts
|
|
132
140
|
async function generate(options) {
|
|
133
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
141
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
142
|
+
if (names.length === 0) {
|
|
143
|
+
console.warn("css-typed-vars: no CSS custom properties found.");
|
|
144
|
+
}
|
|
134
145
|
const outPath = (0, import_node_path.resolve)(options.output);
|
|
135
146
|
await (0, import_promises2.mkdir)((0, import_node_path.dirname)(outPath), { recursive: true });
|
|
136
147
|
if (options.output.endsWith(".js")) {
|
|
@@ -170,29 +181,37 @@ async function loadConfig() {
|
|
|
170
181
|
}
|
|
171
182
|
return {};
|
|
172
183
|
}
|
|
173
|
-
async function run(input, output, exclude, prefix, naming) {
|
|
174
|
-
await generate({ input, output, exclude, prefix, naming });
|
|
184
|
+
async function run(input, output, exclude, prefix, naming, selectors) {
|
|
185
|
+
await generate({ input, output, exclude, prefix, naming, selectors });
|
|
175
186
|
console.log(`Generated \u2192 ${output}`);
|
|
176
187
|
}
|
|
177
188
|
async function main() {
|
|
189
|
+
if (args.includes("--version") || args.includes("-v")) {
|
|
190
|
+
const pkg = JSON.parse(await (0, import_promises3.readFile)(new URL("../package.json", importMetaUrl), "utf8"));
|
|
191
|
+
console.log(pkg.version);
|
|
192
|
+
process.exit(0);
|
|
193
|
+
}
|
|
178
194
|
const config = await loadConfig();
|
|
179
195
|
const input = getArg("--input") ?? config.input;
|
|
180
196
|
const output = getArg("--output") ?? config.output;
|
|
181
197
|
const exclude = getArg("--exclude") ?? config.exclude;
|
|
182
198
|
const prefix = getArg("--prefix") ?? config.prefix;
|
|
183
199
|
const naming = getArg("--naming") ?? config.naming;
|
|
200
|
+
const selectorArg = getArg("--selector");
|
|
201
|
+
const selectors = selectorArg ? [selectorArg] : config.selectors;
|
|
184
202
|
if (!input || !output) {
|
|
185
203
|
console.error("Usage: css-typed-vars --input <glob> --output <file> [--watch]");
|
|
186
204
|
console.error("Or add a css-typed-vars.config.js file with input and output fields.");
|
|
187
205
|
process.exit(1);
|
|
188
206
|
}
|
|
189
|
-
await run(input, output, exclude, prefix, naming);
|
|
207
|
+
await run(input, output, exclude, prefix, naming, selectors);
|
|
190
208
|
if (watchMode) {
|
|
191
209
|
const patterns = Array.isArray(input) ? input : [input];
|
|
192
|
-
|
|
193
|
-
console.log(
|
|
194
|
-
run(input, output, exclude, prefix, naming).catch(console.error);
|
|
195
|
-
}
|
|
210
|
+
const makeHandler = (label) => (file) => {
|
|
211
|
+
console.log(`${label}: ${file}`);
|
|
212
|
+
run(input, output, exclude, prefix, naming, selectors).catch(console.error);
|
|
213
|
+
};
|
|
214
|
+
(0, import_chokidar.watch)(patterns).on("change", makeHandler("Changed")).on("add", makeHandler("Added")).on("unlink", makeHandler("Removed"));
|
|
196
215
|
console.log("Watching for changes...");
|
|
197
216
|
}
|
|
198
217
|
}
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
generate
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-Z7K77FZI.js";
|
|
5
|
+
import "./chunk-B6LVS5G7.js";
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
8
8
|
import { readFile } from "fs/promises";
|
|
@@ -36,29 +36,37 @@ async function loadConfig() {
|
|
|
36
36
|
}
|
|
37
37
|
return {};
|
|
38
38
|
}
|
|
39
|
-
async function run(input, output, exclude, prefix, naming) {
|
|
40
|
-
await generate({ input, output, exclude, prefix, naming });
|
|
39
|
+
async function run(input, output, exclude, prefix, naming, selectors) {
|
|
40
|
+
await generate({ input, output, exclude, prefix, naming, selectors });
|
|
41
41
|
console.log(`Generated \u2192 ${output}`);
|
|
42
42
|
}
|
|
43
43
|
async function main() {
|
|
44
|
+
if (args.includes("--version") || args.includes("-v")) {
|
|
45
|
+
const pkg = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
|
|
46
|
+
console.log(pkg.version);
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
44
49
|
const config = await loadConfig();
|
|
45
50
|
const input = getArg("--input") ?? config.input;
|
|
46
51
|
const output = getArg("--output") ?? config.output;
|
|
47
52
|
const exclude = getArg("--exclude") ?? config.exclude;
|
|
48
53
|
const prefix = getArg("--prefix") ?? config.prefix;
|
|
49
54
|
const naming = getArg("--naming") ?? config.naming;
|
|
55
|
+
const selectorArg = getArg("--selector");
|
|
56
|
+
const selectors = selectorArg ? [selectorArg] : config.selectors;
|
|
50
57
|
if (!input || !output) {
|
|
51
58
|
console.error("Usage: css-typed-vars --input <glob> --output <file> [--watch]");
|
|
52
59
|
console.error("Or add a css-typed-vars.config.js file with input and output fields.");
|
|
53
60
|
process.exit(1);
|
|
54
61
|
}
|
|
55
|
-
await run(input, output, exclude, prefix, naming);
|
|
62
|
+
await run(input, output, exclude, prefix, naming, selectors);
|
|
56
63
|
if (watchMode) {
|
|
57
64
|
const patterns = Array.isArray(input) ? input : [input];
|
|
58
|
-
|
|
59
|
-
console.log(
|
|
60
|
-
run(input, output, exclude, prefix, naming).catch(console.error);
|
|
61
|
-
}
|
|
65
|
+
const makeHandler = (label) => (file) => {
|
|
66
|
+
console.log(`${label}: ${file}`);
|
|
67
|
+
run(input, output, exclude, prefix, naming, selectors).catch(console.error);
|
|
68
|
+
};
|
|
69
|
+
watch(patterns).on("change", makeHandler("Changed")).on("add", makeHandler("Added")).on("unlink", makeHandler("Removed"));
|
|
62
70
|
console.log("Watching for changes...");
|
|
63
71
|
}
|
|
64
72
|
}
|
package/dist/esbuild.cjs
CHANGED
|
@@ -44,20 +44,24 @@ var import_promises = require("fs/promises");
|
|
|
44
44
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
45
45
|
|
|
46
46
|
// src/parser.ts
|
|
47
|
-
function parseVarNames(css) {
|
|
47
|
+
function parseVarNames(css, selectors) {
|
|
48
48
|
const stripped = css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "");
|
|
49
49
|
const names = /* @__PURE__ */ new Set();
|
|
50
|
-
const
|
|
51
|
-
for (const
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const allSelectors = [":root", ...selectors ?? []];
|
|
51
|
+
for (const sel of allSelectors) {
|
|
52
|
+
const escaped = sel.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
53
|
+
const regex = new RegExp(`${escaped}[^{]*\\{([^}]*)\\}`, "g");
|
|
54
|
+
for (const match of stripped.matchAll(regex)) {
|
|
55
|
+
for (const prop of match[1].matchAll(/--[\w-]+(?=\s*:)/g)) {
|
|
56
|
+
names.add(prop[0]);
|
|
57
|
+
}
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
return [...names];
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
// src/scanner.ts
|
|
60
|
-
async function scanVarNames(patterns, exclude) {
|
|
64
|
+
async function scanVarNames(patterns, exclude, selectors) {
|
|
61
65
|
const normalized = (Array.isArray(patterns) ? patterns : [patterns]).map(
|
|
62
66
|
(p) => p.replace(/\\/g, "/")
|
|
63
67
|
);
|
|
@@ -67,7 +71,7 @@ async function scanVarNames(patterns, exclude) {
|
|
|
67
71
|
await Promise.all(
|
|
68
72
|
files.map(async (file) => {
|
|
69
73
|
const css = await (0, import_promises.readFile)(file, "utf8");
|
|
70
|
-
for (const name of parseVarNames(css)) {
|
|
74
|
+
for (const name of parseVarNames(css, selectors)) {
|
|
71
75
|
all.add(name);
|
|
72
76
|
}
|
|
73
77
|
})
|
|
@@ -133,7 +137,7 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => ({
|
|
|
133
137
|
configureServer(server) {
|
|
134
138
|
server.watcher.on("change", async (file) => {
|
|
135
139
|
if (!/\.(css|scss|less)$/i.test(file)) return;
|
|
136
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
140
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
137
141
|
const dtsPath = getDtsPath(options);
|
|
138
142
|
if (dtsPath) {
|
|
139
143
|
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
@@ -149,7 +153,7 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => ({
|
|
|
149
153
|
async buildStart() {
|
|
150
154
|
const dtsPath = getDtsPath(options);
|
|
151
155
|
if (!dtsPath) return;
|
|
152
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
156
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
153
157
|
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
154
158
|
},
|
|
155
159
|
resolveId(id) {
|
|
@@ -157,7 +161,7 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => ({
|
|
|
157
161
|
},
|
|
158
162
|
async load(id) {
|
|
159
163
|
if (id === RESOLVED_ID) {
|
|
160
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
164
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
161
165
|
return generateJs(names, options.prefix, options.naming);
|
|
162
166
|
}
|
|
163
167
|
}
|
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -46,20 +46,24 @@ var import_promises = require("fs/promises");
|
|
|
46
46
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
47
47
|
|
|
48
48
|
// src/parser.ts
|
|
49
|
-
function parseVarNames(css) {
|
|
49
|
+
function parseVarNames(css, selectors) {
|
|
50
50
|
const stripped = css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "");
|
|
51
51
|
const names = /* @__PURE__ */ new Set();
|
|
52
|
-
const
|
|
53
|
-
for (const
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
const allSelectors = [":root", ...selectors ?? []];
|
|
53
|
+
for (const sel of allSelectors) {
|
|
54
|
+
const escaped = sel.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
55
|
+
const regex = new RegExp(`${escaped}[^{]*\\{([^}]*)\\}`, "g");
|
|
56
|
+
for (const match of stripped.matchAll(regex)) {
|
|
57
|
+
for (const prop of match[1].matchAll(/--[\w-]+(?=\s*:)/g)) {
|
|
58
|
+
names.add(prop[0]);
|
|
59
|
+
}
|
|
56
60
|
}
|
|
57
61
|
}
|
|
58
62
|
return [...names];
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
// src/scanner.ts
|
|
62
|
-
async function scanVarNames(patterns, exclude) {
|
|
66
|
+
async function scanVarNames(patterns, exclude, selectors) {
|
|
63
67
|
const normalized = (Array.isArray(patterns) ? patterns : [patterns]).map(
|
|
64
68
|
(p) => p.replace(/\\/g, "/")
|
|
65
69
|
);
|
|
@@ -69,7 +73,7 @@ async function scanVarNames(patterns, exclude) {
|
|
|
69
73
|
await Promise.all(
|
|
70
74
|
files.map(async (file) => {
|
|
71
75
|
const css = await (0, import_promises.readFile)(file, "utf8");
|
|
72
|
-
for (const name of parseVarNames(css)) {
|
|
76
|
+
for (const name of parseVarNames(css, selectors)) {
|
|
73
77
|
all.add(name);
|
|
74
78
|
}
|
|
75
79
|
})
|
|
@@ -138,7 +142,10 @@ function generateDeclaration(varNames, prefix, naming) {
|
|
|
138
142
|
|
|
139
143
|
// src/index.ts
|
|
140
144
|
async function generate(options) {
|
|
141
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
145
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
146
|
+
if (names.length === 0) {
|
|
147
|
+
console.warn("css-typed-vars: no CSS custom properties found.");
|
|
148
|
+
}
|
|
142
149
|
const outPath = (0, import_node_path.resolve)(options.output);
|
|
143
150
|
await (0, import_promises2.mkdir)((0, import_node_path.dirname)(outPath), { recursive: true });
|
|
144
151
|
if (options.output.endsWith(".js")) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { N as NamingConvention } from './generator-Ba8XeISD.cjs';
|
|
2
2
|
export { g as generateCode, a as generateDeclaration, b as generateJs } from './generator-Ba8XeISD.cjs';
|
|
3
3
|
|
|
4
|
-
declare function parseVarNames(css: string): string[];
|
|
4
|
+
declare function parseVarNames(css: string, selectors?: string[]): string[];
|
|
5
5
|
|
|
6
|
-
declare function scanVarNames(patterns: string | string[], exclude?: string | string[]): Promise<string[]>;
|
|
6
|
+
declare function scanVarNames(patterns: string | string[], exclude?: string | string[], selectors?: string[]): Promise<string[]>;
|
|
7
7
|
|
|
8
8
|
interface GenerateOptions {
|
|
9
9
|
input: string | string[];
|
|
@@ -11,6 +11,7 @@ interface GenerateOptions {
|
|
|
11
11
|
exclude?: string | string[];
|
|
12
12
|
prefix?: string;
|
|
13
13
|
naming?: NamingConvention;
|
|
14
|
+
selectors?: string[];
|
|
14
15
|
}
|
|
15
16
|
declare function generate(options: GenerateOptions): Promise<void>;
|
|
16
17
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { N as NamingConvention } from './generator-Ba8XeISD.js';
|
|
2
2
|
export { g as generateCode, a as generateDeclaration, b as generateJs } from './generator-Ba8XeISD.js';
|
|
3
3
|
|
|
4
|
-
declare function parseVarNames(css: string): string[];
|
|
4
|
+
declare function parseVarNames(css: string, selectors?: string[]): string[];
|
|
5
5
|
|
|
6
|
-
declare function scanVarNames(patterns: string | string[], exclude?: string | string[]): Promise<string[]>;
|
|
6
|
+
declare function scanVarNames(patterns: string | string[], exclude?: string | string[], selectors?: string[]): Promise<string[]>;
|
|
7
7
|
|
|
8
8
|
interface GenerateOptions {
|
|
9
9
|
input: string | string[];
|
|
@@ -11,6 +11,7 @@ interface GenerateOptions {
|
|
|
11
11
|
exclude?: string | string[];
|
|
12
12
|
prefix?: string;
|
|
13
13
|
naming?: NamingConvention;
|
|
14
|
+
selectors?: string[];
|
|
14
15
|
}
|
|
15
16
|
declare function generate(options: GenerateOptions): Promise<void>;
|
|
16
17
|
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-Z7K77FZI.js";
|
|
4
4
|
import {
|
|
5
5
|
generateCode,
|
|
6
6
|
generateDeclaration,
|
|
7
7
|
generateJs,
|
|
8
8
|
parseVarNames,
|
|
9
9
|
scanVarNames
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-B6LVS5G7.js";
|
|
11
11
|
export {
|
|
12
12
|
generate,
|
|
13
13
|
generateCode,
|
package/dist/rollup.cjs
CHANGED
|
@@ -44,20 +44,24 @@ var import_promises = require("fs/promises");
|
|
|
44
44
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
45
45
|
|
|
46
46
|
// src/parser.ts
|
|
47
|
-
function parseVarNames(css) {
|
|
47
|
+
function parseVarNames(css, selectors) {
|
|
48
48
|
const stripped = css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "");
|
|
49
49
|
const names = /* @__PURE__ */ new Set();
|
|
50
|
-
const
|
|
51
|
-
for (const
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const allSelectors = [":root", ...selectors ?? []];
|
|
51
|
+
for (const sel of allSelectors) {
|
|
52
|
+
const escaped = sel.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
53
|
+
const regex = new RegExp(`${escaped}[^{]*\\{([^}]*)\\}`, "g");
|
|
54
|
+
for (const match of stripped.matchAll(regex)) {
|
|
55
|
+
for (const prop of match[1].matchAll(/--[\w-]+(?=\s*:)/g)) {
|
|
56
|
+
names.add(prop[0]);
|
|
57
|
+
}
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
return [...names];
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
// src/scanner.ts
|
|
60
|
-
async function scanVarNames(patterns, exclude) {
|
|
64
|
+
async function scanVarNames(patterns, exclude, selectors) {
|
|
61
65
|
const normalized = (Array.isArray(patterns) ? patterns : [patterns]).map(
|
|
62
66
|
(p) => p.replace(/\\/g, "/")
|
|
63
67
|
);
|
|
@@ -67,7 +71,7 @@ async function scanVarNames(patterns, exclude) {
|
|
|
67
71
|
await Promise.all(
|
|
68
72
|
files.map(async (file) => {
|
|
69
73
|
const css = await (0, import_promises.readFile)(file, "utf8");
|
|
70
|
-
for (const name of parseVarNames(css)) {
|
|
74
|
+
for (const name of parseVarNames(css, selectors)) {
|
|
71
75
|
all.add(name);
|
|
72
76
|
}
|
|
73
77
|
})
|
|
@@ -133,7 +137,7 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => ({
|
|
|
133
137
|
configureServer(server) {
|
|
134
138
|
server.watcher.on("change", async (file) => {
|
|
135
139
|
if (!/\.(css|scss|less)$/i.test(file)) return;
|
|
136
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
140
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
137
141
|
const dtsPath = getDtsPath(options);
|
|
138
142
|
if (dtsPath) {
|
|
139
143
|
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
@@ -149,7 +153,7 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => ({
|
|
|
149
153
|
async buildStart() {
|
|
150
154
|
const dtsPath = getDtsPath(options);
|
|
151
155
|
if (!dtsPath) return;
|
|
152
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
156
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
153
157
|
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
154
158
|
},
|
|
155
159
|
resolveId(id) {
|
|
@@ -157,7 +161,7 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => ({
|
|
|
157
161
|
},
|
|
158
162
|
async load(id) {
|
|
159
163
|
if (id === RESOLVED_ID) {
|
|
160
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
164
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
161
165
|
return generateJs(names, options.prefix, options.naming);
|
|
162
166
|
}
|
|
163
167
|
}
|
package/dist/rollup.js
CHANGED
package/dist/unplugin.cjs
CHANGED
|
@@ -42,20 +42,24 @@ var import_promises = require("fs/promises");
|
|
|
42
42
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
43
43
|
|
|
44
44
|
// src/parser.ts
|
|
45
|
-
function parseVarNames(css) {
|
|
45
|
+
function parseVarNames(css, selectors) {
|
|
46
46
|
const stripped = css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "");
|
|
47
47
|
const names = /* @__PURE__ */ new Set();
|
|
48
|
-
const
|
|
49
|
-
for (const
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const allSelectors = [":root", ...selectors ?? []];
|
|
49
|
+
for (const sel of allSelectors) {
|
|
50
|
+
const escaped = sel.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
51
|
+
const regex = new RegExp(`${escaped}[^{]*\\{([^}]*)\\}`, "g");
|
|
52
|
+
for (const match of stripped.matchAll(regex)) {
|
|
53
|
+
for (const prop of match[1].matchAll(/--[\w-]+(?=\s*:)/g)) {
|
|
54
|
+
names.add(prop[0]);
|
|
55
|
+
}
|
|
52
56
|
}
|
|
53
57
|
}
|
|
54
58
|
return [...names];
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
// src/scanner.ts
|
|
58
|
-
async function scanVarNames(patterns, exclude) {
|
|
62
|
+
async function scanVarNames(patterns, exclude, selectors) {
|
|
59
63
|
const normalized = (Array.isArray(patterns) ? patterns : [patterns]).map(
|
|
60
64
|
(p) => p.replace(/\\/g, "/")
|
|
61
65
|
);
|
|
@@ -65,7 +69,7 @@ async function scanVarNames(patterns, exclude) {
|
|
|
65
69
|
await Promise.all(
|
|
66
70
|
files.map(async (file) => {
|
|
67
71
|
const css = await (0, import_promises.readFile)(file, "utf8");
|
|
68
|
-
for (const name of parseVarNames(css)) {
|
|
72
|
+
for (const name of parseVarNames(css, selectors)) {
|
|
69
73
|
all.add(name);
|
|
70
74
|
}
|
|
71
75
|
})
|
|
@@ -131,7 +135,7 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => ({
|
|
|
131
135
|
configureServer(server) {
|
|
132
136
|
server.watcher.on("change", async (file) => {
|
|
133
137
|
if (!/\.(css|scss|less)$/i.test(file)) return;
|
|
134
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
138
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
135
139
|
const dtsPath = getDtsPath(options);
|
|
136
140
|
if (dtsPath) {
|
|
137
141
|
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
@@ -147,7 +151,7 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => ({
|
|
|
147
151
|
async buildStart() {
|
|
148
152
|
const dtsPath = getDtsPath(options);
|
|
149
153
|
if (!dtsPath) return;
|
|
150
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
154
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
151
155
|
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
152
156
|
},
|
|
153
157
|
resolveId(id) {
|
|
@@ -155,7 +159,7 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => ({
|
|
|
155
159
|
},
|
|
156
160
|
async load(id) {
|
|
157
161
|
if (id === RESOLVED_ID) {
|
|
158
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
162
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
159
163
|
return generateJs(names, options.prefix, options.naming);
|
|
160
164
|
}
|
|
161
165
|
}
|
package/dist/unplugin.d.cts
CHANGED
package/dist/unplugin.d.ts
CHANGED
package/dist/unplugin.js
CHANGED
package/dist/vite.cjs
CHANGED
|
@@ -44,20 +44,24 @@ var import_promises = require("fs/promises");
|
|
|
44
44
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
45
45
|
|
|
46
46
|
// src/parser.ts
|
|
47
|
-
function parseVarNames(css) {
|
|
47
|
+
function parseVarNames(css, selectors) {
|
|
48
48
|
const stripped = css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "");
|
|
49
49
|
const names = /* @__PURE__ */ new Set();
|
|
50
|
-
const
|
|
51
|
-
for (const
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const allSelectors = [":root", ...selectors ?? []];
|
|
51
|
+
for (const sel of allSelectors) {
|
|
52
|
+
const escaped = sel.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
53
|
+
const regex = new RegExp(`${escaped}[^{]*\\{([^}]*)\\}`, "g");
|
|
54
|
+
for (const match of stripped.matchAll(regex)) {
|
|
55
|
+
for (const prop of match[1].matchAll(/--[\w-]+(?=\s*:)/g)) {
|
|
56
|
+
names.add(prop[0]);
|
|
57
|
+
}
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
return [...names];
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
// src/scanner.ts
|
|
60
|
-
async function scanVarNames(patterns, exclude) {
|
|
64
|
+
async function scanVarNames(patterns, exclude, selectors) {
|
|
61
65
|
const normalized = (Array.isArray(patterns) ? patterns : [patterns]).map(
|
|
62
66
|
(p) => p.replace(/\\/g, "/")
|
|
63
67
|
);
|
|
@@ -67,7 +71,7 @@ async function scanVarNames(patterns, exclude) {
|
|
|
67
71
|
await Promise.all(
|
|
68
72
|
files.map(async (file) => {
|
|
69
73
|
const css = await (0, import_promises.readFile)(file, "utf8");
|
|
70
|
-
for (const name of parseVarNames(css)) {
|
|
74
|
+
for (const name of parseVarNames(css, selectors)) {
|
|
71
75
|
all.add(name);
|
|
72
76
|
}
|
|
73
77
|
})
|
|
@@ -133,7 +137,7 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => ({
|
|
|
133
137
|
configureServer(server) {
|
|
134
138
|
server.watcher.on("change", async (file) => {
|
|
135
139
|
if (!/\.(css|scss|less)$/i.test(file)) return;
|
|
136
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
140
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
137
141
|
const dtsPath = getDtsPath(options);
|
|
138
142
|
if (dtsPath) {
|
|
139
143
|
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
@@ -149,7 +153,7 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => ({
|
|
|
149
153
|
async buildStart() {
|
|
150
154
|
const dtsPath = getDtsPath(options);
|
|
151
155
|
if (!dtsPath) return;
|
|
152
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
156
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
153
157
|
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
154
158
|
},
|
|
155
159
|
resolveId(id) {
|
|
@@ -157,7 +161,7 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => ({
|
|
|
157
161
|
},
|
|
158
162
|
async load(id) {
|
|
159
163
|
if (id === RESOLVED_ID) {
|
|
160
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
164
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
161
165
|
return generateJs(names, options.prefix, options.naming);
|
|
162
166
|
}
|
|
163
167
|
}
|
package/dist/vite.js
CHANGED
package/dist/webpack.cjs
CHANGED
|
@@ -44,20 +44,24 @@ var import_promises = require("fs/promises");
|
|
|
44
44
|
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
45
45
|
|
|
46
46
|
// src/parser.ts
|
|
47
|
-
function parseVarNames(css) {
|
|
47
|
+
function parseVarNames(css, selectors) {
|
|
48
48
|
const stripped = css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "");
|
|
49
49
|
const names = /* @__PURE__ */ new Set();
|
|
50
|
-
const
|
|
51
|
-
for (const
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const allSelectors = [":root", ...selectors ?? []];
|
|
51
|
+
for (const sel of allSelectors) {
|
|
52
|
+
const escaped = sel.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
53
|
+
const regex = new RegExp(`${escaped}[^{]*\\{([^}]*)\\}`, "g");
|
|
54
|
+
for (const match of stripped.matchAll(regex)) {
|
|
55
|
+
for (const prop of match[1].matchAll(/--[\w-]+(?=\s*:)/g)) {
|
|
56
|
+
names.add(prop[0]);
|
|
57
|
+
}
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
return [...names];
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
// src/scanner.ts
|
|
60
|
-
async function scanVarNames(patterns, exclude) {
|
|
64
|
+
async function scanVarNames(patterns, exclude, selectors) {
|
|
61
65
|
const normalized = (Array.isArray(patterns) ? patterns : [patterns]).map(
|
|
62
66
|
(p) => p.replace(/\\/g, "/")
|
|
63
67
|
);
|
|
@@ -67,7 +71,7 @@ async function scanVarNames(patterns, exclude) {
|
|
|
67
71
|
await Promise.all(
|
|
68
72
|
files.map(async (file) => {
|
|
69
73
|
const css = await (0, import_promises.readFile)(file, "utf8");
|
|
70
|
-
for (const name of parseVarNames(css)) {
|
|
74
|
+
for (const name of parseVarNames(css, selectors)) {
|
|
71
75
|
all.add(name);
|
|
72
76
|
}
|
|
73
77
|
})
|
|
@@ -133,7 +137,7 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => ({
|
|
|
133
137
|
configureServer(server) {
|
|
134
138
|
server.watcher.on("change", async (file) => {
|
|
135
139
|
if (!/\.(css|scss|less)$/i.test(file)) return;
|
|
136
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
140
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
137
141
|
const dtsPath = getDtsPath(options);
|
|
138
142
|
if (dtsPath) {
|
|
139
143
|
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
@@ -149,7 +153,7 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => ({
|
|
|
149
153
|
async buildStart() {
|
|
150
154
|
const dtsPath = getDtsPath(options);
|
|
151
155
|
if (!dtsPath) return;
|
|
152
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
156
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
153
157
|
await (0, import_promises2.writeFile)(dtsPath, generateDeclaration(names, options.prefix, options.naming), "utf8");
|
|
154
158
|
},
|
|
155
159
|
resolveId(id) {
|
|
@@ -157,7 +161,7 @@ var unplugin_default = (0, import_unplugin.createUnplugin)((options) => ({
|
|
|
157
161
|
},
|
|
158
162
|
async load(id) {
|
|
159
163
|
if (id === RESOLVED_ID) {
|
|
160
|
-
const names = await scanVarNames(options.input, options.exclude);
|
|
164
|
+
const names = await scanVarNames(options.input, options.exclude, options.selectors);
|
|
161
165
|
return generateJs(names, options.prefix, options.naming);
|
|
162
166
|
}
|
|
163
167
|
}
|
package/dist/webpack.js
CHANGED