Skip to content

Remove duplicate properties on matching selectors #10

Open

Description

@mattpilott

I think this could be pretty interesting and useful take the following example:

// Input
.button {
    background-color: black;
    color: white;
    display: block;
}

// Sometime later in the css you may have
.button {
    background-color: thistle;
}

// Outputs
.button {
    background-color: thistle;
    color: white;
    display: block;
}

If you can think of any issues with this please shout

Activity

  1. jonathantneal commented on May 17, 2017

    @jonathantneal
    Member

    @matt3224, I think cssnano will merge these rules if they are sequential. Otherwise, if the selectors are an exact match, I think cssnano will remove the overwritten declarations from the earlier rule(s). Is this right, @ben-eb?

  2. mattpilott commented on May 17, 2017

    @mattpilott
    Author

    Hey @jonathantneal I have just installed cssnano with a little help from @ben-eb && @cmnstmntmn it does not appear to do this out-of-the-box 🙁

  3. mattpilott commented on May 17, 2017

    @mattpilott
    Author

    Ok so looks like csso does this, but not completely I have a test case here. The issue is with css shorthand, not sure if there is another tool that will do this?

  4. marcustisater commented on May 19, 2017

    @marcustisater
    Member

    Here is the original plugin that cssnano uses https://github.com/ben-eb/postcss-discard-duplicates. I think you should post a issue with your test case.

  5. marcustisater commented on May 19, 2017

    @marcustisater
    Member

    Aha.. wait. You are correct... 😅 It will not discard the rule if it has a different property value.

  6. mattpilott commented on May 19, 2017

    @mattpilott
    Author

    Take a look at refresh-sf that works very well, totally what i need. However i cannot get clean-css to work the same way. Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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