nDmitry / grunt-postcss

Apply several post-processors to your CSS using PostCSS.
MIT License
419 stars 57 forks source link

Unable to use object from grunt.config as setting for postcss plugin #81

Closed rogerjohansson closed 8 years ago

rogerjohansson commented 8 years ago

I am trying to process custom properties defined in one CSS file and used in several others by means of the postcss-custom-properties plugin.

To do this I have another task that extracts all properties defined in any CSS files and stores them as an object on grunt.config. I then want to use this as the value for a setting in the plugin:

processors: [
    require('postcss-custom-properties')({
        variables: grunt.config('settings.custom_properties')
    })
]

However I keep getting ”variable [variable name] is undefined and used without a fallback”. I tried writing a simple test plugin and grunt.config('settings.custom_properties') is undefined inside the plugin (because it doesn’t know about the grunt object I suppose). If I instead try to use a grunt template, like this:

variables: '<%= settings.custom_properties %>'

I get that exact text, i.e. the template does not get expanded.

Obviously I’m doing something wrong and would appreciate any help or pointers.

nDmitry commented 8 years ago

This is a duplicate of #13.