-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use async function? #212
Comments
Does the promise returned by |
Any idea of how I diagnose what |
Sorry this was is my bad. I had missed the |
It has to be doing something. A promise can either be pending, resolved, or rejected. Only those three states. If it's still pending after a reasonable amount of time, it's probably hanging. |
That's what I thought, I'm using |
I think what is happening is as soon as I add the await for What I don't know now is how to resolve geting the config file before any of the rest of the code runs. I'm trying to get it to work with a HTML processor I created but I'm struggling to think how I have to write the async functions to get |
I've had time to look at this a bit, and I think I now realise that in order to be able to use the async version of the API the framework I'm using would have to be able to accept a promise which is why I can't get this to work. I've since gone back to using the synchronous version of the API and added a try-catch block to detect if a config file has been found or not. var plugins;
try {
plugins = { plugins } = postcssrc.sync(ctx)
catch (error) {
plugins = []
}
const { css } = await postcss([postcssNested(), autoprefixer(), ...plugins]).process(src, { from: undefined }) |
I've never been able to successfully use the async API in my application and I'm wondering why? Do you have any thoughts?
I'm using:
postcssrc(ctx)
causes this function to break for some reason that I don't understand. If I change to the synchronous API it works fine. I'm not sure how to tell what the error is, all I know is that it doesn't return thecss
when I use thepostcss-load-config
async APIWhat am I doing incorrectly?
The text was updated successfully, but these errors were encountered: