⚠ Breaking
optimizeCssandOptimizeCssPluginprune by the props your app passes (propAware) by default, andoptimizeCarbonCssdoes whenevercontentis given. A Carbon class your app builds from data at runtime (class={"bx--tag--" + color}) is no longer kept by the component allowlist and needssafelist. The CLI keeps--prop-awareopt-in.
Features
- with
optimizeComponentsin the same build, CSS is pruned from the analysis it rewrote for, so JS and CSS come from one reading of the call sites, using svelte-prune's stylesheet pruner with Carbon's IBM Plex, flatpickr and legacybx-rules on top - Carbon's CSS Grid breakpoint classes (
bx--lg:col-span-4) are pruned when noCssColumnrenders them
Performance
- 12–74% smaller optimized CSS in default setups; 1.6–2.6 kB smaller with
optimizeComponents
| Example (optimized CSS) | 0.11.63 | 0.12.0 |
|---|---|---|
vite
| 47.39 kB | 29.24 kB |
sveltekit
| 47.09 kB | 29.02 kB |
vite@carbon-0.85
| 88.22 kB | 26.66 kB |
vite@svelte-5/multiselect
| 159.11 kB | 41.73 kB |
vite@svelte-5/datatable-toolbar
| 80.47 kB | 33.93 kB |
vite@svelte-5/tabs-bundle
| 48.78 kB | 24.08 kB |
rollup, webpack (with optimizeComponents)
| 28.97 kB | 27.15 kB |
Every example renders and behaves identically to its unoptimized build through scripted clicks, menus, modals and tooltips, SvelteKit and Astro hydration included.
Migration
Most apps need no change: prop-aware pruning reads literal props, constants, your wrapper components and Carbon's own call sites, and keeps every variant of anything it can't read.
If a style goes missing, keep the classes your app builds from data:
optimizeCss({ safelist: [/^\.bx--tag--/] });report: true prints each component's prop values, and why any stayed unknown.
To opt out and prune by imported components alone, as in 0.11:
optimizeCss({ propAware: false });
// webpack, Rspack
new OptimizeCssPlugin({ propAware: false });