Skip to content

Add support for basic addVariant plugins with new @plugin directive#13982

Merged
adamwathan merged 17 commits intonextfrom
v4-plugin-api-again
Jul 11, 2024
Merged

Add support for basic addVariant plugins with new @plugin directive#13982
adamwathan merged 17 commits intonextfrom
v4-plugin-api-again

Conversation

@adamwathan
Copy link
Member

This PR adds support for a new @plugin directive as a first step towards reintroducing compatibility with v3 plugins:

@import "tailwindcss";
@plugin "my-plugin";

This PR only introduces support for the addVariant API for now, with support for the other plugin APIs planned for separate PRs.

Just like v3, plugins are JS files that look like this:

// my-plugin.js
module.exports = function ({ addVariant }) {
  addVariant('hocus', ['&:hover', '&:focus'])
}

This PR doesn't reintroduce the tailwindcss/plugin export yet that you can use to wrap plugins that support configuration options, but planning to reintroduce that as well to ensure old plugins continue to work.

@adamwathan adamwathan merged commit 5447408 into next Jul 11, 2024
@adamwathan adamwathan deleted the v4-plugin-api-again branch July 11, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants