soranoo / next-css-obfuscator

A package deeply inspired by PostCSS-Obfuscator but for Next.js.
https://next-css-obfuscator.vercel.app
MIT License
71 stars 3 forks source link

Weird spacing #10

Closed soranoo closed 7 months ago

soranoo commented 7 months ago
          hmm what was that weird spacing

image

Originally posted by @hoangnhan2ka3 in https://github.com/soranoo/next-css-obfuscator/issues/9#issuecomment-1925548768

hoangnhan2ka3 commented 7 months ago

I discovered that when I break a line like this, it will cause the above spacing error:

image

When I put className on the same line as usual, everything is fine:

image

image

But if you actually put it in one line, it would be really long 🥲

hoangnhan2ka3 commented 7 months ago

Oh here we go again https://github.com/soranoo/next-css-obfuscator/issues/4 🫡

hoangnhan2ka3 commented 7 months ago

I don't know, but...

I just tried using cssnano in postcss.config.js and the problem seems to be resolved

image

Multi-line className:

image

Result ✅:

image

Although in production cssnano reports some Parse error or UNKNOWN_DIMENSION errors if you use viewport unit in a calc with other units (?)

eg: calc(100% - 0.94dvw)...

image

But in general, these errors are harmless, so this can be considered an effective temporary method.

hoangnhan2ka3 commented 7 months ago

Or do you have any updates on this issue in v2.1.4 @soranoo ? I hope I don't misunderstand

soranoo commented 7 months ago

2.1.4 is just the official release of 2.1.4-beta.1. Nothing related to this issue.

hoangnhan2ka3 commented 7 months ago

Sorry, I have a problem unrelated to this issue, which is caching.

You know, every time you run build the obfuscate process will start from the beginning, meaning the random obfuscated classes will be completely different from the previous time. This causes nextjs cache related issue.

If a user has visited my page before, then after I update (new deployed), and they reload the page without clearing the cache, it will look like this:

image

And no matter how many times they try to 'refresh' the website, it will still look the same.

Unless they press Ctrl + Shift + R (aka hard reload), the site is updated.

image

Even when I try view page source without hard reload, the css file doesn't have any new obfuscated class, which causes an error like my website doesn't have css at all.

Do you have the same problem in your version of Next Js, or do you have any advice for me, I've been searching for it all night.

hoangnhan2ka3 commented 7 months ago

The problem probably only occurs when I enable next-css-obfuscator.

If you don't enable it from the beginning, the TW classes will just update the new values ​​after each deployment, and the old classes don't need to be changed, and it will be cached, I think.

soranoo commented 7 months ago

Please open a new issue for ANY ISSUE NOT related to the current one.

hoangnhan2ka3 commented 7 months ago

Yes, I just wanted to ask your opinion if this is considered an issue with this plugin 🫡.

soranoo commented 7 months ago

Since the issue was not caused by this package, I decided to leave it alone.