postcss / postcss-custom-properties

Use Custom Properties in CSS
https://postcss.github.io/postcss-custom-properties
MIT License
597 stars 77 forks source link

Process CSS synchronously? Plus add example to DOC. #236

Open nolimitdev opened 3 years ago

nolimitdev commented 3 years ago

1.) Is sync way available? I see in source code in index.cjs.js that it should return sync function when there is no import and export in options const canReturnSyncFunction = importFrom.length === 0 && exportTo.length === 0; but it seem to do nothing, always Promise/LazyResult is returned.

2.) Also it would be nice to add example here https://github.com/postcss/postcss-custom-properties/blob/master/INSTALL.md#node how to process CSS text and get it returned (not exported to file) because it took some time for me to understand how it works. There should be example(s):

var result = await PostcssCustomProperties.process('...YOUR_CSS_TO_PROCESS...', /* processOptions: */ { from: undefined },  /* pluginOptions: */ { preserve : false  });
console.log(result.css);
PostcssCustomProperties.process('...YOUR_CSS_TO_PROCESS...', /* processOptions: */ { from: undefined },  /* pluginOptions: */ { preserve : false  })
    .then((result) => {
        console.log(result.css);
    });