Skip to content

Support configuring a single list of variants to apply to all relevant plugins #852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2019

Conversation

adamwathan
Copy link
Member

@adamwathan adamwathan commented Apr 18, 2019

Closes #851.

This PR makes it possible for users to specify a global variants configuration that should be applied to all utilities by assigning an array of variants directly to the variants property in their tailwind.config.js file:

module.exports  = {
  variants: ['responsive', 'group-hover', 'hover', 'focus']
}

This is useful for Purgecss users who just want everything available and don't want to micro-optimize at the individual plugin level.

No breaking changes here technically but plugin authors would be encouraged to update their plugins to use the new variants function made available through the plugin API to look up the variants for their plugin instead of using the config function.

- function({ addUtilities, config }) {
+ function({ addUtilities, variants }) {
    addUtilities(
      {
        '.content-center': {
          'align-content': 'center',
        },
      },
-     config('variants.alignContent')
+     variants('alignContent')
    )
  }

This will ensure that your plugin respects the users global variants configuration if they choose to use this feature.

@reinink
Copy link
Member

reinink commented Apr 18, 2019

Thank you Adam.

Long live modules: 'all'!!!!!!!!!!!!

Sincerely,
Jonathan

@adamwathan adamwathan merged commit daea662 into next Apr 18, 2019
@adamwathan adamwathan deleted the global-variants branch April 18, 2019 14:17
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