elcrm 1.1.8 → 1.1.9
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.
|
@@ -45,6 +45,9 @@ export declare function replaceCssVarToken(
|
|
|
45
45
|
to: string,
|
|
46
46
|
): string;
|
|
47
47
|
|
|
48
|
+
/** Имена `--*` в CSS, без суффиксов BEM-классов. */
|
|
49
|
+
export declare function collectCssVarNames(texts: string[]): string[];
|
|
50
|
+
|
|
48
51
|
export declare function isVendorJsChunk(code: string): boolean;
|
|
49
52
|
|
|
50
53
|
export declare function minifyCssVars(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/vite/minify-css-vars.ts
|
|
2
|
-
var VAR_RE =
|
|
2
|
+
var VAR_RE = /(?<![\w-])--[a-zA-Z_][\w-]*/g;
|
|
3
3
|
var VAR_IN_JS_RE = /var\(\s*(--[a-zA-Z_][\w-]*)|["'](--[a-zA-Z_][\w-]*)["']/g;
|
|
4
4
|
var CLASS_SEL_RE = /\.(-?[_a-zA-Z]+[_a-zA-Z0-9-]*)/g;
|
|
5
5
|
var LETTERS = "abcdefghijklmnopqrstuvwxyz";
|
|
@@ -106,7 +106,10 @@ function escapeRe(s) {
|
|
|
106
106
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
107
107
|
}
|
|
108
108
|
function replaceCssVarToken(text, from, to) {
|
|
109
|
-
return text.replace(new RegExp(
|
|
109
|
+
return text.replace(new RegExp(`(?<![\\w-])${escapeRe(from)}(?![\\w-])`, "g"), to);
|
|
110
|
+
}
|
|
111
|
+
function collectCssVarNames(texts) {
|
|
112
|
+
return [...collect(texts, VAR_RE)].sort();
|
|
110
113
|
}
|
|
111
114
|
function replaceVarsInCss(text, map) {
|
|
112
115
|
let out = text;
|
|
@@ -128,7 +131,11 @@ function isVendorJsChunk(code) {
|
|
|
128
131
|
}
|
|
129
132
|
function replaceClasses(text, map, inCss) {
|
|
130
133
|
let out = text;
|
|
131
|
-
|
|
134
|
+
const entries = byLongest(map.keys()).map((k) => [
|
|
135
|
+
k,
|
|
136
|
+
map.get(k)
|
|
137
|
+
]);
|
|
138
|
+
for (const [from, to] of entries) {
|
|
132
139
|
const esc = escapeRe(from);
|
|
133
140
|
if (inCss) {
|
|
134
141
|
out = out.replace(new RegExp(`\\.${esc}(?![\\w-])`, "g"), `.${to}`);
|
|
@@ -288,5 +295,6 @@ export {
|
|
|
288
295
|
minifyCssVars,
|
|
289
296
|
isVendorJsChunk,
|
|
290
297
|
encodeName,
|
|
298
|
+
collectCssVarNames,
|
|
291
299
|
allocateUnique
|
|
292
300
|
};
|
package/package.json
CHANGED
|
@@ -92,7 +92,7 @@ elcrm test --front|--server|--no-scripts
|
|
|
92
92
|
|
|
93
93
|
### Vite-плагины из пакета `elcrm`
|
|
94
94
|
|
|
95
|
-
Нужен **elcrm ≥ 1.1.
|
|
95
|
+
Нужен **elcrm ≥ 1.1.9** в `devDependencies` приложения (не только глобальный `bun i -g`). Иначе Vite: `Missing "./vite/minify-css-vars"` или BEM-классы ломаются (`--wide` в `.account--wide`).
|
|
96
96
|
|
|
97
97
|
```js
|
|
98
98
|
import { minifyCssVars } from "elcrm/vite/minify-css-vars";
|
|
@@ -101,7 +101,7 @@ import { minifyCssVars } from "elcrm/vite/minify-css-vars";
|
|
|
101
101
|
minifyCssVars({ var: 2, name: 3, classPrefix: "x" })
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
`nameStart` / `varStart` — **числа** (индекс алфавита), не `"x"`. Префикс класса — `classPrefix`. В JS плагин не трогает декремент `--n` (иначе `aqt is not defined`).
|
|
104
|
+
`nameStart` / `varStart` — **числа** (индекс алфавита), не `"x"`. Префикс класса — `classPrefix`. В JS плагин не трогает декремент `--n` (иначе `aqt is not defined`). BEM `.account--wide` — это класс, не переменная `--wide` (иначе CSS и `className` разъедутся).
|
|
105
105
|
|
|
106
106
|
Короткие имена **уникальны и подряд**: `--aa`, `--ab`, `--ac`… Занятые слоты пропускаются; `--field` не затирает `--field-border`. Чанки JSZip не минифицируются (декремент `--n`). Если слотов нет — сборка падает.
|
|
107
107
|
|