You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I have defined some custom variants to integrate with a third-party UI library (Reach UI). These work just fine when developing locally, but in production, the custom variants get purged for some reason.
Here are the relevant parts of my tailwind.config.js:
module.exports={variants: {backgroundColor: [// ...'aria-selected','group-aria-selected','selected','group-selected',],textColor: [// ...'aria-selected','group-aria-selected','selected','group-selected',],fontWeight: [// ...'aria-selected','group-aria-selected','selected','group-selected',],inset: [// ...'aria-selected','group-aria-selected','selected','group-selected',],},plugins: [require('@tailwindcss/ui'),plugin(function({ addVariant, e }){addVariant('aria-selected',({ modifySelectors, separator })=>{modifySelectors(({ className })=>{return`.${e(`aria-selected${separator}${className}`)}[aria-selected="true"]`;});});addVariant('group-aria-selected',({ modifySelectors, separator })=>{modifySelectors(({ className })=>{return`.group[aria-selected="true"] .${e(`group-aria-selected${separator}${className}`)}`;});});addVariant('selected',({ modifySelectors, separator })=>{modifySelectors(({ className })=>{return`.${e(`selected${separator}${className}`)}[data-selected]`;});});addVariant('group-selected',({ modifySelectors, separator })=>{modifySelectors(({ className })=>{return`.group[data-selected] .${e(`group-selected${separator}${className}`)}`;});});}),],purge: {content: ['./components/**/*.js','./pages/**/*.js','./lib/**/*.js'],options: {// NOTE: tested just one variant below, but still did not save the variants from being purgedwhitelist: ['selected:text-teal-400','selected:font-semibold','selected:bg-gray-700'],},},/** * Preparing for Tailwind 2.0: https://tailwindcss.com/docs/upcoming-changes */future: {removeDeprecatedGapUtilities: true,purgeLayersByDefault: true,},};
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! I have defined some custom variants to integrate with a third-party UI library (Reach UI). These work just fine when developing locally, but in production, the custom variants get purged for some reason.
Here are the relevant parts of my
tailwind.config.js
:Here's an example of the variant being used:
Here's a screenshot of the correct
data-selected
attribute being added to the element with correct style being applied in development:Here's a screenshot of the correct
data-selected
attribute being added to the element, but no style being applied in production:Here is a link to repro: (dev mode - can't enable purge here) https://play.tailwindcss.com/jNNp5VPccj
Additional details
:
in thewhitelist
array, but no successselected
to thewhitelist
array, but no successAny thoughts?
Beta Was this translation helpful? Give feedback.
All reactions