dolphincss 1.2.9 → 1.3.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/package.json
CHANGED
package/vite-plugin.js
CHANGED
|
@@ -27,14 +27,16 @@ export default function dolphincssPlugin() {
|
|
|
27
27
|
let newOriginalCode = originalCode;
|
|
28
28
|
|
|
29
29
|
for (const [marker, replacement] of Object.entries(components)) {
|
|
30
|
-
// Regex
|
|
30
|
+
// Regex to match <div className="marker"></div> with any spacing/newlines inside
|
|
31
|
+
// Using [\"'] instead of capture groups to simplify and avoid backreference issues
|
|
31
32
|
const regex = new RegExp(
|
|
32
|
-
`<div\\s+class(?:Name)?=
|
|
33
|
+
`<div\\s+class(?:Name)?=[\"']${marker}[\"']\\s*>\\s*</div>|<div\\s+class(?:Name)?=[\"']${marker}[\"']\\s*/>`,
|
|
33
34
|
'g'
|
|
34
35
|
);
|
|
35
36
|
|
|
36
37
|
if (regex.test(newOriginalCode)) {
|
|
37
|
-
|
|
38
|
+
// IMPORTANT: Use () => replacement to avoid $1, $2 substitution from things like $120.50
|
|
39
|
+
newOriginalCode = newOriginalCode.replace(regex, () => replacement);
|
|
38
40
|
modified = true;
|
|
39
41
|
console.log(`\n✨ DolphinCSS: Injected '${marker}' into ${path.basename(id)}`);
|
|
40
42
|
}
|
|
@@ -54,11 +56,11 @@ export default function dolphincssPlugin() {
|
|
|
54
56
|
let newCode = code;
|
|
55
57
|
for (const [marker, replacement] of Object.entries(components)) {
|
|
56
58
|
const regex = new RegExp(
|
|
57
|
-
`<div\\s+class(?:Name)?=
|
|
59
|
+
`<div\\s+class(?:Name)?=[\"']${marker}[\"']\\s*>\\s*</div>|<div\\s+class(?:Name)?=[\"']${marker}[\"']\\s*/>`,
|
|
58
60
|
'g'
|
|
59
61
|
);
|
|
60
62
|
if (regex.test(newCode)) {
|
|
61
|
-
newCode = newCode.replace(regex, replacement);
|
|
63
|
+
newCode = newCode.replace(regex, () => replacement);
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
|