@webmate-studio/builder 0.2.37 → 0.2.38

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webmate-studio/builder",
3
- "version": "0.2.37",
3
+ "version": "0.2.38",
4
4
  "type": "module",
5
5
  "description": "Webmate Studio Component Builder",
6
6
  "keywords": [
@@ -30,6 +30,44 @@ function loadTailwindStyles() {
30
30
  }
31
31
  }
32
32
 
33
+ /**
34
+ * Strip non-utility layers from Tailwind CSS output
35
+ * Removes @layer base, @layer theme, @layer properties, @property definitions, and Tailwind comments
36
+ * Keeps only @layer utilities content
37
+ * @param {string} css - Full Tailwind CSS
38
+ * @returns {string} CSS with only utilities
39
+ */
40
+ function stripNonUtilityLayers(css) {
41
+ // Remove Tailwind header comments
42
+ css = css.replace(/\/\*!.*?tailwindcss.*?\*\//gs, '');
43
+
44
+ // Remove @layer declarations (but keep the utilities layer)
45
+ css = css.replace(/@layer\s+[^{]*?;\s*/g, '');
46
+
47
+ // Remove @layer base { ... } blocks
48
+ css = css.replace(/@layer\s+base\s*\{[\s\S]*?\n\}/g, '');
49
+
50
+ // Remove @layer theme { ... } blocks
51
+ css = css.replace(/@layer\s+theme\s*\{[\s\S]*?\n\}/g, '');
52
+
53
+ // Remove @layer properties { ... } blocks
54
+ css = css.replace(/@layer\s+properties\s*\{[\s\S]*?\n\}/g, '');
55
+
56
+ // Remove @property definitions
57
+ css = css.replace(/@property\s+[^{]+\{[\s\S]*?\n\}/g, '');
58
+
59
+ // Extract content from @layer utilities { ... }
60
+ const utilitiesMatch = css.match(/@layer\s+utilities\s*\{([\s\S]*)\}/);
61
+ if (utilitiesMatch) {
62
+ css = utilitiesMatch[1].trim();
63
+ }
64
+
65
+ // Clean up multiple newlines
66
+ css = css.replace(/\n{3,}/g, '\n\n');
67
+
68
+ return css.trim();
69
+ }
70
+
33
71
  /**
34
72
  * Extract Tailwind classes from HTML content
35
73
  * @param {string} html - HTML content
@@ -256,21 +294,14 @@ export async function generateTailwindCSS(classes, options = {}) {
256
294
  // For dev builds: include everything
257
295
  let inputCSS;
258
296
 
259
- if (includeBaseLayers) {
260
- // Full Tailwind with all layers (for wm dev)
261
- const themeCSS = generateThemeCSS(themeColors);
262
- inputCSS = `
297
+ // Always use full Tailwind import
298
+ // We'll strip layers afterwards if includeBaseLayers is false
299
+ const themeCSS = includeBaseLayers ? generateThemeCSS(themeColors) : '';
300
+ inputCSS = `
263
301
  @import "tailwindcss";
264
302
 
265
303
  ${themeCSS}
266
- `.trim();
267
- } else {
268
- // Only utilities layer (for component builds)
269
- // Base/theme/properties are provided by CMS design tokens
270
- inputCSS = `
271
- @import "tailwindcss/utilities.css" layer(utilities);
272
- `.trim();
273
- }
304
+ `.trim();
274
305
 
275
306
  // Load Tailwind CSS styles
276
307
  const tailwindStyles = loadTailwindStyles();
@@ -288,7 +319,12 @@ ${themeCSS}
288
319
  });
289
320
 
290
321
  // Build CSS for the specific classes
291
- const result = await compiler.build(classArray);
322
+ let result = await compiler.build(classArray);
323
+
324
+ // If includeBaseLayers is false, strip out base/theme/properties layers
325
+ if (!includeBaseLayers) {
326
+ result = stripNonUtilityLayers(result);
327
+ }
292
328
 
293
329
  return result;
294
330