postcss-use icon indicating copy to clipboard operation
postcss-use copied to clipboard

feat: add PostCSS 8 support

Open Kocal opened this issue 2 years ago • 1 comments

Close #43, close #44

Hi! Some help would be needed here, I'm not familiar with PostCSS plugins at all but we need this one to be compatible with PostCSS 8 in order to run https://github.com/tinovyatkin/postcss-amp on a specifc stylesheet for AMP.

I've already followed https://evilmartians.com/chronicles/postcss-8-plugin-migration to migrate the two plugins (postcss-use and the internal postcss-nobg plugins), but tests fail.

It looks like plugins enabled by @postcss-use are not ran at all, and I don't understand why (putting some console.log({ pluginPath, pluginOpts }) before const plugin = require(pluginPath)(pluginOpts) is working tho).

Friendly ping @ai @ben-eb 🙏 , thanks!

Kocal avatar Jul 30 '22 07:07 Kocal

It looks like plugins enabled by @postcss-use are not ran at all, and I don't understand why (putting some console.log({ pluginPath, pluginOpts }) before const plugin = require(pluginPath)(pluginOpts) is working tho).

They are not called because PostCSS 8 calls prepareVisitors before the run https://github.com/postcss/postcss/blob/main/lib/lazy-result.js#L446

We need to find some trick to re-prepare the cache.

ai avatar Jul 30 '22 22:07 ai