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

Implementing SSR support for astro-rename #4

Open
jkhaui opened this issue Sep 23, 2023 · 5 comments · Fixed by #17
Open

Implementing SSR support for astro-rename #4

jkhaui opened this issue Sep 23, 2023 · 5 comments · Fixed by #17
Assignees
Labels
help wanted Extra attention is needed v2

Comments

@jkhaui
Copy link

jkhaui commented Sep 23, 2023

Hey,

I came across this plugin from google/postcss-rename#43, funnily enough I had the exact same idea so it was nice seeing the great work you've already done to build this integration.

I'm just wondering if you can provide a high-level description of what the main blocker is atm for supporting SSR? That way, I can hopefully contribute to its implementation if I have time and it's not too complex. From a brief glance at the source maybe we'd need to hook into Astro's build:ssr step. Thanks!

@RodrigoTomeES
Copy link
Owner

Hi,

Sorry, I missed this issue. The main issue in SSR is process the file on the fly to transform his classes and keep the state of the transformed classes map.

I think that Astro should be have a hook to implement this but I didn't have time to explore it. Any help would be welcome.

In addition, I found this utiltiy that implement SSR transform for Next.JS but only for Tailwind CSS https://github.com/sonofmagic/tailwindcss-mangle. But maybe it would be interested to take a look of how Sonofmagic implemented it.

@RodrigoTomeES RodrigoTomeES added the help wanted Extra attention is needed label Oct 16, 2023
@RodrigoTomeES RodrigoTomeES self-assigned this Oct 16, 2023
@Tanguy-Magnaudet
Copy link

Hey there,

Astro released in 3.5.0 the ability to use Middlewares in an integration :
https://github.com/withastro/astro/releases/tag/astro%403.5.0

It should now be possible to replace classes names using a middleware like it is shown in the doc here : https://docs.astro.build/en/guides/middleware/#example-redacting-sensitive-information

It will probably be slow but as most of content website have cache, I guess it's ok for now ?

@RodrigoTomeES
Copy link
Owner

@Tanguy-Magnaudet hi!

Maybe can be implemented with a middlewares but I think it more interesting investigate the use the hook "astro:build:ssr". With it you can perform the replacement directly after the generation.

Right now I am working on the v2 of this plugin that will be bring more stability and a safety replacements of the classes. After that I will take this issue, I will investigate also your suggestion.

Thanks!

@RodrigoTomeES RodrigoTomeES linked a pull request Jun 13, 2024 that will close this issue
@RodrigoTomeES
Copy link
Owner

hi, @jkhaui @Tanguy-Magnaudet you can test the early support to SSR in v2 alpha-6 version of the package => https://www.npmjs.com/package/astro-rename/v/2.0.0-alpha6

@jkhaui
Copy link
Author

jkhaui commented Jun 21, 2024

hi, @jkhaui @Tanguy-Magnaudet you can test the early support to SSR in v2 alpha-6 version of the package => https://www.npmjs.com/package/astro-rename/v/2.0.0-alpha6

Very nice, great work! 👏
I'll try it and let you know my thoughts

Sorry I never got a chance to try implement it myself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed v2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants