Skip to content

Layer dependencies break utility css solutions (like tailwindcss) #240

@ZeroAurora

Description

@ZeroAurora

Related: #233 ant-design/x#1588 ant-design/x#559 ant-design/ant-design#56015

Currently, if a layer has dependencies, cssinjs will prepend a @layers deps..., layer.name at the front of header, effectively setting all of these layers the lowest priority.

// ================= Inject Layer Style =================
// Inject layer style
effectLayerKeys.forEach((effectKey) => {
updateCSS(
normalizeStyle(effectStyle[effectKey], autoPrefix || false),
`_layer-${effectKey}`,
{ ...mergedCSSConfig, prepend: true },
);
});

When importing a css in code with bundlers like vite, the css is always placed after the very first @layers statement, therefore having higher priorities.

This has caused multiple issues when used together with utility css solutions like tailwindcss. See the related issues above, which illustrate lots of problems caused by this issue.

For example, it breaks the intended behavior of Ant Design, when used together with Ant Design X. Minimal reproducible project here. To put it simple: If you are developing with antd + antd/x + tailwindcss, it just breaks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions