pascalduez / postcss-apply

PostCSS plugin enabling custom properties sets references
The Unlicense
164 stars 12 forks source link

How to use with webpack? #9

Closed chimon2000 closed 7 years ago

chimon2000 commented 7 years ago

I am attempting to use this feature in webpack, but I cannot figure out how to inject custom properties. This is fairly easy to do for var

        let variables = {
            'primary-toolbar': '#415464',
            'secondary-toolbar': "#488fb4"
        }
            require("postcss-cssnext")({
                features: {
                    customProperties: {
                        variables: variables,
                        'conversation-progress': `
                            {
                                margin: 0 auto;
                                position: fixed;
                                top: 50%;
                                left: 50%;
                            };
                        `
                    },
                    applyRule: {
                    }
                }
            })

However when attempting to do something similar for apply I get the no custom properties set declared error.

pascalduez commented 7 years ago

Hi,

this has nothing to do with webpack, it's just that there's no mechanism implemented to create custom property sets from js/config.

chimon2000 commented 7 years ago

That's what I assumed, thanks for the clarification. Since I'm using angular2, my use case isn't as simple as just plugging everything into one file. As a workaround, I'm using postcss-inject to inject :root into my components' css.

kevinSuttle commented 7 years ago

@chimon2000: See https://github.com/postcss/postcss-custom-properties/issues/32#issuecomment-237363712

pascalduez commented 7 years ago

Refs #15