maximkoretskiy / postcss-autoreset

PostCSS plugin for automatic rules isolation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

duplicate declarations

moimikey opened this issue · comments

I didn't see any open/closed issue for this, but I have the following input:

html, body {
  height: 100%;
}

body {
  position: relative;
}

and of course, my postcss config:

const sharedPlugins = webpack => ([
  require('postcss-import')({
    addDependencyTo: webpack,
    path: ['node_modules', 'src/app'],
    plugins: [
      require('postcss-discard-duplicates')()
    ]
  }),
  require('postcss-url')(),
  require('postcss-cssnext')(),
  require('postcss-discard-duplicates')(),
  require('postcss-font-magician')(),
  require('postcss-autoreset')(),
  require('lost')(),
])

but get this as output:

html, body,
body {
  all: initial;
}

html, body {
  height: 100%;
}

body {
  position: relative;
}

regardless of whether or not i'm misusing postcss-discard-duplicates, it doesn't have any effect on this scenario.

is there a way to avoid the duplication of body without having to be careful?

Hi! To avoid result code duplication autoreset groups all the rules. source -> result

And there are no any arguments to break this optimization. To make sources more compact U can use cssnano(btw U also use it in css-loader)

Anyway if you want to use postcss-discard-duplicates, try to move it to the end of plugin list.

thanks @maximkoretskiy. ill reopen if i experience any issues.

just noting that having postcss-discard-duplicates at the end doesn't help ._.