dolphincss 1.2.8 → 1.2.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.
- package/package.json +1 -1
- package/vite-plugin.js +15 -26
package/package.json
CHANGED
package/vite-plugin.js
CHANGED
|
@@ -27,21 +27,16 @@ export default function dolphincssPlugin() {
|
|
|
27
27
|
let newOriginalCode = originalCode;
|
|
28
28
|
|
|
29
29
|
for (const [marker, replacement] of Object.entries(components)) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
`<div
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
`<div className='${marker}'></div>`,
|
|
36
|
-
`<div class='${marker}'></div>`
|
|
37
|
-
];
|
|
30
|
+
// Regex matches <div className="marker"></div> with optional spaces/newlines inside, or self-closing <div className="marker" />
|
|
31
|
+
const regex = new RegExp(
|
|
32
|
+
`<div\\s+class(?:Name)?=(["'])${marker}\\1\\s*>\\s*</div>|<div\\s+class(?:Name)?=(["'])${marker}\\2\\s*/>`,
|
|
33
|
+
'g'
|
|
34
|
+
);
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
console.log(`\n✨ DolphinCSS: Injected '${marker}' into ${path.basename(id)}`);
|
|
44
|
-
}
|
|
36
|
+
if (regex.test(newOriginalCode)) {
|
|
37
|
+
newOriginalCode = newOriginalCode.replace(regex, replacement);
|
|
38
|
+
modified = true;
|
|
39
|
+
console.log(`\n✨ DolphinCSS: Injected '${marker}' into ${path.basename(id)}`);
|
|
45
40
|
}
|
|
46
41
|
}
|
|
47
42
|
|
|
@@ -58,18 +53,12 @@ export default function dolphincssPlugin() {
|
|
|
58
53
|
// Also apply the replacement to the current transform stream
|
|
59
54
|
let newCode = code;
|
|
60
55
|
for (const [marker, replacement] of Object.entries(components)) {
|
|
61
|
-
const
|
|
62
|
-
`<div
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
`<div class='${marker}'></div>`
|
|
68
|
-
];
|
|
69
|
-
for (const pattern of cases) {
|
|
70
|
-
if (newCode.includes(pattern)) {
|
|
71
|
-
newCode = newCode.split(pattern).join(replacement);
|
|
72
|
-
}
|
|
56
|
+
const regex = new RegExp(
|
|
57
|
+
`<div\\s+class(?:Name)?=(["'])${marker}\\1\\s*>\\s*</div>|<div\\s+class(?:Name)?=(["'])${marker}\\2\\s*/>`,
|
|
58
|
+
'g'
|
|
59
|
+
);
|
|
60
|
+
if (regex.test(newCode)) {
|
|
61
|
+
newCode = newCode.replace(regex, replacement);
|
|
73
62
|
}
|
|
74
63
|
}
|
|
75
64
|
|