Skip to content

How to use async function? #212

@gavinmcfarland

Description

@gavinmcfarland

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:

async function processPostCSS(src = '') {
	const ctx = { parser: true, map: 'inline' };

	const { plugins } = await postcssrc(ctx)
	const { css } = await postcss([postcssNested(), autoprefixer(), ...plugins]).process(src, { from: undefined })

	return css
}

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 the css when I use the postcss-load-config async API

What am I doing incorrectly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions