postcss / postcss-use

Enable PostCSS plugins directly in your stylesheet.
MIT License
152 stars 16 forks source link

passing array options doesn't work #38

Closed jhessin closed 6 years ago

jhessin commented 6 years ago
@use postcss-pxtorem ({
  prop_white_list:[
    'width', 'height', 'font',
    'font-size', 'line-height', 'letter-spacing'
  ]
})

This throws the following error:

Module build failed: ModuleBuildError: Module build failed: ParseError: /Users/jameshessin/local/websites/generator-coffee-mithril/generators/app/templates/src/styles/home.styl:3:1
   1| @use postcss-pxtorem ({
   2|   prop_white_list:[
   3|     'width', 'height', 'font',
------^
   4|     'font-size', 'line-height', 'letter-spacing'
   5|   ]
   6| })

unexpected ","

The Readme says that you can pass parameters as a JSON object, but this doesn't seem to work and I can't figure out how to get it to.

jonathantneal commented 6 years ago

@jhessin, you’ve passed in a JavaScript object, but not a JSON object. Consider your code:

{
  prop_white_list: [
    'width', 'height', 'font',
    'font-size', 'line-height', 'letter-spacing'
   ]
}

Now, consider this valid JSON alternative:

{
  "prop_white_list": [
    "width", "height", "font",
    "font-size", "line-height", "letter-spacing"
   ]
}

Please let me know if this resolved your issue. You may also want to validate your JSON beforehand: https://jsonlint.com/