pascalduez / postcss-apply

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

Consider adding a `preserve` option #14

Closed pascalduez closed 7 years ago

pascalduez commented 8 years ago

https://github.com/postcss/postcss-custom-properties#preserve

kevinSuttle commented 8 years ago

I've noticed that when you combine this plugin with postcss-custom-properties and add preserve: true, you get double CSS Custom Properties, but nothing preserved, which triggers the error found here: https://github.com/pascalduez/postcss-apply/blob/master/src/visitor.js#L57

No preserve option set in postcss-custom-properties

new webpack.LoaderOptionsPlugin({
        options: {
          postcss: function (webpack) {
            return [
              cssApply,
              customProperties({
                variables: colorPalettes, // JS object from file
                warnings: false
              }),
              autoprefixer,
            ]
          }
        }
screen shot 2016-09-30 at 2 17 26 am

preserve: true option set in postcss-custom-properties

new webpack.LoaderOptionsPlugin({
        options: {
          postcss: function (webpack) {
            return [
              cssApply,
              customProperties({
                variables: colorPalettes, 
+               preserve: true,
                warnings: false
              }),
              autoprefixer,
            ]
          }
        }
screen shot 2016-09-30 at 2 16 50 am
pascalduez commented 8 years ago

I'll try to add more unit tests with postcss-custom-properties options.

When reporting, please provides simple cases/samples/tests reproducing the issue. Without any Webpack, Storybook and such. This is not a proper way to report bugs.

pascalduez commented 7 years ago

Available from version 0.5.0 on.