cuth / postcss-pxtorem

Convert pixel units to rem (root em) units using PostCSS
MIT License
2.03k stars 174 forks source link

replace option is not working as expected #36

Closed feedmypixel closed 7 years ago

feedmypixel commented 7 years ago

I have set up postcss-cli v3.2.0 using the postcss.config.js as instructed here

package.json

My npm script is:

"postbuild:css": "postcss dist/assets/stylesheets/*.css -d dist/assets/stylesheets/ --parser sugarss

postcss.config.js

This is in my root directory

module.exports = (ctx) => ({
  parser: ctx.file.extname === '.sss' ? ctx.options.parser : false,
  map: ctx.options.map,
  plugins: {
    'postcss-pxtorem': {
      rootValue: 16,
      unitPrecision: 5,
      selectorBlackList: [],
      replace: false,
      mediaQuery: false,
      minPixelValue: 0,
      propWhiteList: [
        'font',
        'font-size',
        'line-height',
        'letter-spacing',
        'padding',
        'padding-top',
        'padding-right',
        'padding-bottom',
        'padding-left',
        'margin',
        'margin-top',
        'margin-right',
        'margin-bottom',
        'margin-left',
        'width',
        'height',
        'border-radius',
        'letter-spacing'
      ]
    },
    autoprefixer: {
      browsers: [
        '> 2%',
        'last 2 versions',
        'ie >= 7'
      ]
    }
  }
})

When running the above script against my CSS I would expect to see:

.highlight{
  font-size: 24px;
  font-size: 1.5rem
}

But with the option replaced set to false I currently see:

.highlight{
  font-size:1.5rem
}

Of Note

a) The above config is definitely being picked up because changing the contents of the propWhiteList option works as expected and is reflected in the outputted css file.

b) setting up a node script as described here with the option replaced set to false works as expected.

c) I am not sure this is connected but I could not get the postcss.config.js to be picked up or get it to work by any of the methods described in the migration guide. The only way it has worked is as described above via this issue comment from @michael-ciniawsky potentially this is causing an issue here with the replaced option not being respected?

feedmypixel commented 7 years ago

After a machine restart this morning it is working as intended. Seems to be a non issue or something was stuck in a cache somewhere - Odd!