unocss: [Bug Report] Latest update broke styling for flexbox properties in Nuxt3
UnoCSS version
0.58.7
Describe the bug
Upon updating Unocss to v0.58.7 in my Nuxt3 portfolio this morning, I notice a number of styles simply no longer work. Notably flexbox properties (and sometimes borders). This does not seem to have an effect on live production.
Here is a pic of a section in my portfolio in dev mode vs live - the styles have not changed at all between these two images. It seems that this issue only happens on the initial load of the page, although it can sometimes revert back to this state when I save changes on a file or component:
*These images are showing that flex, items-center, and justify-between not being applied to these elements. Again, styles have not been changed or edited in any way. Only the unocss version has changed.
Reproduction
I can’t seem to reproduce this in a Stackblitz as it seems to be local environment issue… But here is the gist of what I have in my project, which always seems to be unstyled upon page load:
System Info
Nuxt v3.11.1
Node v18.18.2
Validations
- Read the Contributing Guidelines.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (4 by maintainers)
@Simon-He95 The issue is that this is extremely difficult to reproduce. It also seems to not happen within new Nuxt projects, even when I have the same config as my older projects. I have tried with two new repos to reproduce the issue locally and simply cannot do it (despite spending hours on the issue this past weekend). Perhaps I need to remove my node modules folder or uninstall/reinstall uno on my older projects?
Agreed @owl1n. This definitely seems like a potential
@applyissue, although I am still somewhat unsure of the core cause…At its core, it seems that some css styles are simply not applied when using
@apply. However, it seems to be infrequent and mainly occurs on flexbox type styles. I will need help from any other Nuxt users to find the issue here, although I will keep at it during this week. Even another video that can screen-record the styles not being applied may help.@Simon-He95
Here it is https://stackblitz.com/edit/sveltekit-unocss-4zjjuo
@Simon-He95 I will try to find a way to create an online repo
nice job,I will try to fix it
A bit more digging. I tested the following in my SvelteKit project. Issue arises when multiple
@applyare defined. For the following example,@apply shadow-lgstyle appears to be ignored in the final result.Issue can be resolved by combine style utilities into a single
@apply. (Or by removing thesimicolonOffsetlogic mentioned before)However, such outcome doesn’t seem to be reproduced on UnoCSS Playground. https://unocss.dev/play/?version=0.58.7&html=DwEwlgbgBAxgNgQwM5ILwCIAuBTJn0B8AKrpsAPTgQFA&config=PTAEFMGcBsEsDsAuBaAJrSBDARtcz5wAPFOQ0eAe2QCcpEbYBjRcVZWAWwAdKbFIAKC69%2BoAN6DQoVOABmCcAGFK8BQHMANFNANM8SHL6dwNACKw6LWADco26dzqRwiAIKIGsbAFdEsOQBPB1AnKFcAVSpBAF9QORpKTlAAch8qJkhIFMFBYlFEGXlMH2hC2QVCFTVYdQAKSUdnV0gALlAAbR0m8MQoyjqAShCel3dPRl9-IKGQgF0QvQMjGhMaNs7u3Rp9Q2NTCyt-O0hZnTnYwcEgA&css=HQFwpgziAEDeBQ1oAECGAHdAbAntCAFqgCYD2A7gLRYDmA3IihtngE6kCuAdsWMZQFti0AEY1KELKnCUAzAAZ5%2BImSqoBIsK0oBWRQwC%2BQA&options=N4IgLgTghgdgzgMwPYQLYGECucxIwZXxAC4EoAbOAUwBpxp5k0AJMVcksyqgXyA So far the issue is only visible in an actual SvelteKit+Vite project.
Can confirm. I ended up switching to tailwind because this is a prevalent issue in Unocss with Nuxt. Maybe check out @microdou post above @Simon-He95?
I will temporarily close this issue first, and you are welcome to open it at any time when a reproducible demo is provided.
With last version of nuxt its actual to me too. Some apply rules like width and height + flex rules sometimes not transform to css. Or it can work in development but not in production.