Enhancing Metadata Extraction in TailwindCSS #15037
sonofmagic
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
@sonofmagic Hey! I'm curious what kind of use case you have for this? We did add support for this into Oxide (the Rust part that extracts the candidates) when we started working on the Upgrade tooling so depending on what you want to build, this new API might be helpful for you? Take a look at this API: https://github.com/tailwindlabs/tailwindcss/blob/next/crates/oxide/src/lib.rs#L133-L152 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Enhancing Metadata Extraction in TailwindCSS
Current Situation
When
tailwindcss
extractsCandidate
tokens from files or content, it only retrieves the string values without recording their specific locations. For example:However, this limited metadata makes it challenging to conduct comprehensive project-level analysis. Specifically:
Lack of Contextual Metadata
Challenges in Post-Processing
Proposed Solution: Enhanced Candidate Representation
To solve these issues, tokens should be converted into an enriched object structure, such as:
Where:
value
is the original string token.file
specifies the source file the token came from.start
andend
indicate the token's position within the file.Benefits of this Approach
Accurate Analysis
We gain a clear overview of the tokens extracted from each file and their exact locations.
Precise Modifications
For example, modifying a token string can now be achieved with precision:
Rather than applying modifications indiscriminately to all files or across the entire
Candidates
set (which risks unintended side effects), this method allows targeting specific files and precise positions for updates.Implementation Considerations
This functionality is akin to what
unocss
provides with itscompile-class
feature. Adding similar functionality totailwindcss
would enhance its flexibility and utility, especially for advanced use cases involving dynamic or project-level token management.Beta Was this translation helpful? Give feedback.
All reactions