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

[Feature Request] Support to merge duplicate code #6

Open
fengyuanchen opened this issue Nov 24, 2017 · 5 comments
Open

[Feature Request] Support to merge duplicate code #6

fengyuanchen opened this issue Nov 24, 2017 · 5 comments

Comments

@fengyuanchen
Copy link

Current:

@block btn {
  color: #333;

  &:disabled {
    color: #ccc;
  }

  @modifier disabled {
    color: #ccc;
  }
}

Feature:

@block btn {
  color: #333;

  &:disabled,
  @modifier disabled {
    color: #ccc;
  }
}
@tbremer
Copy link
Owner

tbremer commented Nov 27, 2017

I don't plan to support this, there are two plugins postcss-merge-rules and postcss-merge-selectors that enable this type of code tidying.

Those plugins combined with postcsss-nested would let this work out.

@tbremer tbremer closed this as completed Nov 27, 2017
@fengyuanchen
Copy link
Author

Not work with the following config (postcss.config.js):

module.exports = {
  plugins: {
    'postcss-atrule-bem': {},
    'postcss-merge-rules': {}, // or 'postcss-merge-selectors': {},
    'postcss-nested': {},
  },
};

Or:

module.exports = {
  plugins: {
    'postcss-atrule-bem': {},
    'postcss-nested': {},
    'postcss-merge-rules': {},  // or 'postcss-merge-selectors': {},
  },
};

@fengyuanchen
Copy link
Author

Only works after removed at-rule as this:

@block btn {
  color: #333;

  &:disabled,
  &[disabled] {
    color: #ccc;
  }
}

@tbremer
Copy link
Owner

tbremer commented Nov 30, 2017

I was able to get this working with postcss-merge-rules as the last plugin in my setup: https://runkit.com/tbremer/5a2039571ab5510012be0073

@tbremer tbremer reopened this Nov 30, 2017
@fengyuanchen
Copy link
Author

I mean support to write merge rules in source css, not merge rules automatically in bundled css: https://runkit.com/cfy/5a20ba024fb2d10011dac2b8

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