@gustcss/vite 0.9.2 → 0.10.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 CHANGED
@@ -70,6 +70,46 @@ Create `gustcss.config.json` in your project root:
70
70
  }
71
71
  ```
72
72
 
73
+ ### Production Class-Name Mangling
74
+
75
+ Enable `mangleClassNames` to shorten generated selectors and matching source references during `vite build`.
76
+
77
+ Development mode keeps readable class names.
78
+
79
+ ```javascript
80
+ export default defineConfig({
81
+ plugins: [
82
+ gustcss({
83
+ output: 'src/styles/utility.css',
84
+ mangleClassNames: true,
85
+ mangleExclude: ['public-hook'],
86
+ }),
87
+ ],
88
+ })
89
+ ```
90
+
91
+ The manifest defaults to `<output>.classes.json`; set `mangleMap` to use another path. A path inside Vite's `outDir` is fine: the plugin writes the manifest again after `emptyOutDir` runs.
92
+
93
+ Treat the manifest as generated output and ignore it in Git unless your workflow intentionally pins class mappings.
94
+
95
+ The transformer supports HTML, JavaScript, TypeScript, JSX, and TSX. It rewrites static `class` and `className` attributes, static template segments, direct string arguments to `classList`, and `setAttribute('class', ...)`. Code examples inside HTML `<code>` and `<pre>` bodies are neither rewritten nor inspected; classes on the elements themselves are still rewritten. An unclosed `<code>` or `<pre>` fails the build instead of masking the remainder of the document.
96
+
97
+ JavaScript, TypeScript, JSX, and TSX transforms emit Source Map v3 mappings back to the original source. Comments and ordinary strings containing `class="..."` are not treated as JSX attributes. An ordinary string that still references a mapped class fails closed as ambiguous.
98
+
99
+ Conditional expressions, nested calls, selectors, and other ambiguous references fail the build. The plugin restores readable CSS after a failed transform.
100
+
101
+ Add dynamically or externally referenced class names, including production E2E selectors, to `mangleExclude`.
102
+
103
+ Vue, Astro, and Svelte templates are not supported by this option yet. A mapped class in one of these files fails the build instead of emitting mismatched output.
104
+
105
+ Files under `node_modules` are neither rewritten nor inspected.
106
+
107
+ Short names avoid every class token found in the scanned `content` files, `safelist`, and `mangleExclude`. One- or two-letter classes defined outside `content` can still collide; add them to `mangleExclude`.
108
+
109
+ `el.className = '...'` assignments are not rewritten and fail the build when they contain a mapped class. Use `setAttribute('class', ...)` or `classList` instead.
110
+
111
+ This optimization is not available through the PostCSS plugin because PostCSS cannot rewrite application markup and JavaScript.
112
+
73
113
  ## Features
74
114
 
75
115
  ### ⚡️ Development Mode
@@ -83,6 +123,7 @@ Create `gustcss.config.json` in your project root:
83
123
  - Generates optimized CSS at build time
84
124
  - Only includes utilities used in your code
85
125
  - No runtime overhead
126
+ - Optional production-only class-name mangling with no runtime overhead
86
127
 
87
128
  ## How It Works
88
129