Open Hugos68 opened 3 hours ago
It is intended behavior. The plugin configuration logic follows that of presets:
The following options in
tailwind.config.js
simply replace the same option if present in a preset:
content
darkMode
prefix
important
variantOrder
separator
safelist
We can also see in the source code:
It explicitly merges theme
, corePlugins
and plugins
, but the rest of the configuration keys are "collapsed", replacing each other (via the defaults()
function).
Can/will this ever change? It makes authoring plugins in some scenario's a bit difficult. As I'm authoring a component library that utilises tailwind so the end user needs to configure their content path to include our package inside node_modules. It would be awesom if our already present tailwind plugin could handle this for them.
As a work-around, you could consider having consumers wrap their configuration object in a function you export
:
import { tailwindConfigWrapperFunction } = 'my-library';
export default tailwindConfigWrapperFunction({
// Consumer Tailwind configuration.
});
This would allow you to augment the configuration as desired.
What version of Tailwind CSS are you using?
What build tool (or framework if it abstracts the build tool) are you using?
What version of Node.js are you using?
What browser are you using?
What operating system are you using?
Reproduction URL
Unsure how to reproduce in tailwind.play as it's a config issue and I can't access the post merge config.
Describe your issue
In the tailwind docs it states quote:
So when doing the following:
I would expect the merged config to look like:
But the actual resulted config is:
This means because the
content
field is present in the config, the plugin'scontent
field is completely ignored. This makes authoring plugins more painful as know I need to instruct users to add stuff to theircontent
field manually instead of have my plugin do this for them.Is this intended behaviour?