Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BCL builder] Make postcss prefixer option more flexible #591

Open
vever001 opened this issue Jul 1, 2024 · 2 comments
Open

[BCL builder] Make postcss prefixer option more flexible #591

vever001 opened this issue Jul 1, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@vever001
Copy link

vever001 commented Jul 1, 2024

Problem

BCL builder allows passing the prefix option when compiling sass files, but it is not flexible enough as it only passes the prefix and not the entire postcss-prefix-selector config which we would need.

Also, the plugin gets run with an empty prefix when no prefix are specified, which I believe is slowing down the compilation for no reason. And the current transform callback is not necessary and optional.

Context:

We would need such feature/flexibility for ckeditor5 stylesheets which expects all CSS to be prefixed with ".ck-content", but we need to specify the transform callback to deal with ":root".
Also relates to openeuropa/oe_bootstrap_theme#404
To be:

{
  entry: path.resolve(baseDir, "resources/sass/style.scss"),
  dest: path.resolve(baseDir, "assets/css/ckeditor5-style.css"),
  options: {
    ...
    prefixer: {
      prefix: ".ck-content",
      // Replace ":root" with prefix.
      transform: (prefix, selector, prefixedSelector) => {
        if (selector.includes(":root")) {
          return selector.replace(/:root/g, prefix);
        }
        return prefixedSelector;
      }
    }
  }
}

Proposed resolution

Deprecate the prefix option in favor of prefixer which holds the entire prefixer config.
Run the plugin only when one of these options is passed.

@tibi2303
Copy link
Collaborator

ok, i am going to recreate the same pr on bcl directly, the solution seems good on my side

@vever001
Copy link
Author

vever001 commented Sep 16, 2024

Why? Personally I don't mind but this isn't promoting contributions...
I understand you may need to further refine the code or create a dedicated branch but in this case the code is exactly the same between PRs... Why no cherry picking?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants