postcss / postcss-use

Enable PostCSS plugins directly in your stylesheet.
MIT License
152 stars 16 forks source link

feat: add PostCSS 8 support #45

Closed Kocal closed 3 months ago

Kocal commented 2 years ago

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!

ai commented 2 years ago

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.