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

Conflicts with other postcss plugins #157

Closed
Bygaga63 opened this issue Sep 4, 2023 · 1 comment
Closed

Conflicts with other postcss plugins #157

Bygaga63 opened this issue Sep 4, 2023 · 1 comment

Comments

@Bygaga63
Copy link

Bygaga63 commented Sep 4, 2023

Hello, cool lib.
I faced with interesing bug: when i try to use this plugin with another one, i see interesting issue:

const postcss = require("postcss");

let input = `
.dashed-class {
  color: green;
  &_foo {
    color: blue;
  }

  &.bar {
    background: green;
  }
}
`;

let instance = postcss([
    require("postcss-nested"),
    require("postcss-modules-local-by-default")({mode: 'local'})
]);

instance.process(input).then((result) => {
    console.log(result.css);
});

Return

:local(.dashed-class) {
  color: green;
}
  :local(.dashed-class)_foo {
    color: blue;
  }
  :local(.dashed-class):local(.bar) {
    background: green;
  }

Problem with

  :local(.dashed-class)_foo {
    color: blue;
  }

I think should be

  :local(.dashed-class_foo) {
    color: blue;
  }

I debuged and found that Rule method in postcss-nested' is called after Onceinpostcss-modules-local-by-default. Do you have any idea how to wait for rule result in postcss-nested'.
I only solution i found was to run process twice - get css from postcss-nested', and run again with postcss-modules-local-by-default`

Maybe there is a better solution? Or i'm doing something wrong?
Thanks.

@ai
Copy link
Member

ai commented Sep 4, 2023

The best way is to convert postcss-modules-local-by-default from Once method to proper Rule, etc.

The possible conflicts between plugins are the reason why we are asking users to avoid using Once.

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

No branches or pull requests

2 participants