Skip to content

Switch to PostCSS Async API #43

Description

@josh

According to the latest PostCSS plugin guidelines, plugins should "use asynchronous methods when it is possible". Theres a number of places postcss-url makes blocking FS calls.

In order to clean this up, the postcss plugin API will need to return a Promise which will mark it as async forcing consumers to use process(css).then(cb). This would probably be considered a major backwards incompatible change.

But I think it would be worth while to align to the plugin best practices as this plugin is listed under the official @postcss org.

There could be other benefits besides this cleanup. For one, I think it would be great to support async logic in the custom url function.

"postcss-url": {
  url: function(url) {
    return asyncCallToComputeAssetMD5(url).then(function(md5) {
      return url + "?" + md5
    })
  }
}

I'd be happy to help work on this. But I just wanted to get an idea if this would be a welcome direction.

Thanks!

CC: @MoOx @ai

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