Use Tailwind's resolveConfig
helper to load the final merged/resolved config
#3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The recommended way of loading Tailwind config programmatically is to use the
resolveConfig
helper. The reason for this is that in most Tailwind setups, any customtheme
config is merged with a set of default config. If we justrequire
the config file directly then we will have access to the customtheme
config, but not to any of the default values.I realised after mentioning this to @hankchizljaw on Twitter that this isn't as useful as I thought it might be for this repo as the prototype creates a set of config items completely from scratch by providing an empty
presets
array in the Tailwind config, so there are no default values being used, just the values being explicitly set inside the Tailwind config file.Still, it doesn't hurt to load the config this way and it might be useful for others using this repo as an example, or if, in the future, a client removes the
presets
config item. As an example, this would let them create custom properties for theborderRadius
values provided by Tailwind's default theme, even if they didn't have a customisedborderRadius
object in their Tailwind config file'stheme
section.