csstools/precss

Setting preset-env options?

Opened this issue · 3 comments

marr commented

Hi, thanks for this plugin [collection]. I am trying to set the importFrom option for the preset-env plugin. Are those options set at the root, or is there a prefix that we need to know about?

My postcss.config.js looks like this:

import precss from 'precss';
const options = {
  importFrom: './variables.css',
}
module.exports = () => ({
  plugins: [precss(options)]
})

However, the css I'm compiling appears not to find the variables declared in variables.css.

Hello, @marr .

I had the same doubt, but by reading the way options are passed to the plugins, it seems that every option is passed to every plugin: https://github.com/jonathantneal/precss/blob/master/src/index.js

So all you have to do is to set the options at the root.

I guess there are no collisions between options names across plugins, otherwise it should be problematic.

5lava commented

There are some collisions. For example, postcss-custom-properties and postcss-custom-media share the same option names preserve, importFrom, exportTo.

Documentation at https://github.com/jonathantneal/precss/wiki/Options refers to version 2.0.0. Starting from 3.0.0 there's no way to split options. As @luislhl said, every option is passed to every plugin.

Hello there,

I´ve been working on solving this problem, currently waiting for feedback on my PR #132
Will keep you guys updated!

Have a good one :)