@illlia/css-merge
Version:
css-merge is a tiny package to compose css classes on the 'last class wins' basis
39 lines (29 loc) • 1.52 kB
TypeScript
import { PluginCreator } from "postcss";
import { CompressedConfig } from "./css-merge";
/**
TODO: performance: tw-merge add caching?
Comparing value & priority instead of just priority -->
i.e
most after classes have "content: var(...)" line, if value is the same for 2 classes it's ok to add them both
i.e x2
p-2, px-3 > p-2 px-3 OR px-3 ? --> p-2 px-3
px-3, p-2 > p-2 OR px-3 p-2 ? --> p-2
px-2 px-3 > px-3 OR px-2 px-3 ? -->
px-3 px-2 > px-2
>> if value is different, remove it? but how do i know if class updates other values that might be needed (p-2 pr-3)
Is there any harm in tracking "order" when checking for conflicts? Will it create a weird behavoir that will change the output classNames
based on internal component implementation + passed overrides?
Ex. ...
Goal: to make overrides non-dependent on internal component styling with deterministic results
(doesn't matter if base component is using `px-2 py-2` or `p-2`)
Ex.
const BaseComponent = tw(div)`...`
const ParentComponent = () => <BaseComponent class="..." />
TODO: handle !important modifier correctly (may not adhere to order rule)
- should it just be a logic inside tw-merge to not touch those? or should the users still be able to override them
TODO: how much perf did i save by minimizing ? compare minimized VS non-minimized config
*/
export declare const postcssPlugin: PluginCreator<{
onParsed: (data: CompressedConfig) => void;
}>;
export declare const writeConfig: (path: string) => (data: CompressedConfig) => Promise<void>;