Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: A more useful compilation mode #948

Closed
UltraCakeBakery opened this issue May 8, 2022 · 4 comments · Fixed by #950
Closed

Feature request: A more useful compilation mode #948

UltraCakeBakery opened this issue May 8, 2022 · 4 comments · Fixed by #950

Comments

@UltraCakeBakery
Copy link
Contributor

Now that unocss can do transforms, I am wondering how easy it would be to add support for a more useful compilation mode compared to the one from windicss. One where you can also manually pick what elements get their classes and attributes combined into one.

EXAMPLE:

Before:

<!-- note the additional `compile` class at the beginning -->
<div class="compile bg-red-500 text-xl font-bold border border-gray-200 dark:hover:bg-green-500 transform scale-5">

After:

<div class="uno-2xjw9">
@UltraCakeBakery UltraCakeBakery changed the title A more useful compilation mode Feature request: A more useful compilation mode May 8, 2022
@antfu
Copy link
Member

antfu commented May 8, 2022

Well, originally I was going to say this is out-of-scope since it would be a lot of caveats to do it right (in Windi it's only supported in CLI but not the Vite plugin). But with your proposal of adding the compile key making it explicit, and actually becomes possible to do!

The word compile might be a bit too general, but I guess once we figure out a nice-looking one we could ever support it in string literals. Like (say ::uno:: for example)

<script setup>
const styling = '::uno:: bg-red-500 text-xl font-bold border border-gray-200` // to be `uno-2xjw9`
</script>

<template>
  <div :class="styling">
</template>

I like this idea!

@antfu
Copy link
Member

antfu commented May 8, 2022

Implemented at #950

@antfu antfu closed this as completed in #950 May 9, 2022
@UltraCakeBakery
Copy link
Contributor Author

UltraCakeBakery commented May 9, 2022

@antfu that was implemented very quickly! Thank you for this! I have not gotten around to testing it yet. Will do in the near future.

@MehrdadKhnzd
Copy link

I didn't find a way to make it work with Attributify. Is there a way to do that?
If not, would it be possible to have the same mechanism for that as well using the attributes' prefix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants