Skip to content

formatter_css: Support PostCSS plugin syntax? #23969

Description

@leaysgur

https://github.com/why-reproductions-are-required/bun-vite-template/blob/master/src/components/Welcome/Welcome.module.css

.title {
  color: light-dark(var(--mantine-color-black), var(--mantine-color-white));
  font-size: rem(100px);
  font-weight: 900;
  letter-spacing: rem(-2px);

  @media (max-width: $mantine-breakpoint-md) {
    font-size: rem(50px);
  }
}

For now, Oxfmt (oxc_formatter_css) reports error for this .css file.
Since $mantine-breakpoint-md is NOT a valid CSS syntax, this comes from postcss-simple-vars extension.

On the other hand, Prettier originally uses postcss-parser, and as its parsing is lenient, it does not throw an error.

As far as Mantine (this snippet) is concerned, other plugins such as postcss-mixins are also used, and all of them are reported as invalid CSS. https://github.com/mantinedev/postcss-preset-mantine

Some plugin syntaxes are already supported. "Supported" here means it can parse and at least be printed as-is (verbatim).


We previously decided NOT to support these PostCSS plugin syntaxes because they are not as widely used as they once were.
However, we may reconsider this due to the fact that they still have a certain number of users, and to maintain compatibility with Prettier.

That said, since supporting every single plugin is realistically impossible, we are considering narrowing down the scope to support only a select few.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-formatterArea - FormatterF-lang-cssFormatter - oxc_formatter_css related

    Fields

    Priority

    None yet

    Start date

    None yet

    Target date

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions