jsx to html with Vite #12877
Unanswered
LazerRaptor
asked this question in
Q&A
Replies: 1 comment
-
|
looking for an answer too! anyone? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
Firstly, some context. I am Django backend dev and I am quite new to Vite. In the Django community there is a growth of popularity of a so-called low-JS approach where instead of using full-fledged JS apps, the old SSR approach is used with some enhancements by libraries like
htmxandAlpine.js. The biggest drawback, at least to my eye, of this approach is that it leads to a somewhat messy code and a bit ugly-looking syntax. And, overall, it doesn't benefit fully from the rich Node.js eco-system. But this is where Vite.js can help, I believe.If I use
Alpine.jswith a Django template together, I will do something like this (here we inject{{ content }}from Django provided context):It looks alright until our pages become big and the logic more complex. That's why I'd like to try an alternative: to use JSX and generate Django templates from it:
The above is all normal for Alpine.js, except for the
render()method. What I'd like to do is to compile what this method returns into an HTML document and use it by Django.So what I'd like to try is take render's return and compile html templates from it, e.g. when I request them in my root file:
so it would create an
example.htmlfile in the specified template directory.I need to delve into this and I'd really appreciate some general directions to get started.
E.g. I'd like to know if I can rely on some Vite.js internals to render jsx or should I try something like vhtml, which config options should I be looking at, which parts of the documentation, etc.
Thanks a lot.
Beta Was this translation helpful? Give feedback.
All reactions