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
feat(presets): configurable separator #1791
Conversation
✅ Deploy Preview for unocss ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
9b8af36
to
b52a8f9
Compare
I am not sure if the complexity is it worth here. And I didn't find a strong reason why the separator needs to be configurable. Anyone share more context? |
b52a8f9
to
3413135
Compare
3413135
to
52dc8f7
Compare
@tjk please excuse me for the ping. I'd like to ask for your take |
I personally think it's very highly worth it since tailwind allows configuring separator and if someone uses Maybe you can tell us what you think the suggestion is for someone trying to migrate a large codebase with a custom separator then if you don't want this merged? Maybe somehow memoizing the entire substring |
This PR changes quite a lot of static regex into dynamic ones. Static regex is one of the key reasons UnoCSS is fast, as the JS engine could do JIT optimization and compile them to native code. While on the other hand, creating regex in every pass breaks that and would decrease the performance quite a bit. For your need, it's actually quite simple to do with a one-line variant: export default defineConfig({
variants: [
(selector) => selector.replace(/_/g, '-')
],
presets: [
presetUno(),
presetAttributify(),
]
}) |
I've updated the regexes that can be cached; otherwise, the variant approach is acceptable too |
2f39c97
to
88e4eb0
Compare
88e4eb0
to
6f46d5c
Compare
d20b753
to
5c6006b
Compare
d20a9fb
to
c0d1e96
Compare
11311a9
to
af1bcb7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Let's ship it in the next minor
This PR adds configurable separator to the three built-in presets.
Reference: #1573, #1704
Edit: rebase commit