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
@twind/cli is a utility that can greatly help in some cases, however in practice it can also:
yield "false positives" (i.e. detect TailwindCSS classes / selectors that are not actually used, due to broad string-based / regular expression search)
give false impressions (e.g. class names generated by Twind at runtime via css()apply() and style() cannot possibly be computed via static code analysis, so the CLI-generated stylesheet is likely incomplete in most realistic use-cases).
These known limitations / caveats are absolutely acceptable, but I think the scope of this CLI utility should be documented in the README (i.e. stating goals and non-goals) so that users don't get caught off-guard / waste their time when considering their options.
There are probably several different use-cases for this CLI utility, such as producing useful development-time information, or pre-populating static stylesheets in production builds. On this latter point, if there are indeed benefits in using a pre-rendered stylesheet in combination with the Twind runtime in a live HTML page, then perhaps the README should mention it? (based on my experience, it is my understanding that there is zero advantage in doing this, in fact in my view this would just add unnecessary bytes to the total size of prerendered resources, as the Twind runtime already contains all the non-trivial logic to produce class names and CSS rules just-in-time ... maybe I am not correct, and I am always happy to be proven wrong / to learn :)
rounded is not actually a used class, it is just a "word" found in a string
:root body { --tw-bg-opacity:1; background-color: #fef3c7; background-color: rgba(254, 243, 199, var(--tw-bg-opacity)); } is missing from the generated stylesheet, which is completely understandable, as it would normally be generated by the Twind runtime via css(). Instead, the .bg-yellow-100 { } class CSS selector is generated, but this is in fact not used in the content (and therefore wastes bytes).
The goal description is definitely missing. It was an exercise to show a tool similar to tailwindcss could be implemented on top of the existing twind code.
Hello :)
@twind/cli
is a utility that can greatly help in some cases, however in practice it can also:css()
apply()
andstyle()
cannot possibly be computed via static code analysis, so the CLI-generated stylesheet is likely incomplete in most realistic use-cases).These known limitations / caveats are absolutely acceptable, but I think the scope of this CLI utility should be documented in the README (i.e. stating goals and non-goals) so that users don't get caught off-guard / waste their time when considering their options.
There are probably several different use-cases for this CLI utility, such as producing useful development-time information, or pre-populating static stylesheets in production builds. On this latter point, if there are indeed benefits in using a pre-rendered stylesheet in combination with the Twind runtime in a live HTML page, then perhaps the README should mention it? (based on my experience, it is my understanding that there is zero advantage in doing this, in fact in my view this would just add unnecessary bytes to the total size of prerendered resources, as the Twind runtime already contains all the non-trivial logic to produce class names and CSS rules just-in-time ... maybe I am not correct, and I am always happy to be proven wrong / to learn :)
Code reference:
twind-cli/src/extract.ts
Lines 4 to 46 in 1f1b677
Example:
twind.html
=>
twind.config.js
=>
npx @twind/cli ./**/*.html -b -c twind.config.js
=>
Issues:
rounded
is not actually a used class, it is just a "word" found in a string:root body { --tw-bg-opacity:1; background-color: #fef3c7; background-color: rgba(254, 243, 199, var(--tw-bg-opacity)); }
is missing from the generated stylesheet, which is completely understandable, as it would normally be generated by the Twind runtime viacss()
. Instead, the.bg-yellow-100 { }
class CSS selector is generated, but this is in fact not used in the content (and therefore wastes bytes).css()
andapply()
PS: it would be awesome if support for CSS Modules
composes
was available more broadly, wouldn't it :)https://github.com/css-modules/css-modules#composition
The text was updated successfully, but these errors were encountered: