dotnet / aspire-samples

MIT License
668 stars 196 forks source link

Vite React Typescript example #402

Open michaelto20 opened 2 months ago

michaelto20 commented 2 months ago

With many new projects using Vite and Typescript with React, I struggled to find many examples or documentation on how to do that. I figured out the configuration and rewrote the weather sample app using Vite, Typescript, and React and would like to add that to the samples folder. Does this seem valuable and should I submit a PR for it?

davidfowl commented 2 months ago

cc @IEvangelist

IEvangelist commented 2 months ago

There are so many variations of SPA flavors out there, and just as many opinions. I'd be curious, what was the configuration bits required and what value does another JS SPA example add? If the only delta is the config, I'm not so sure I'm sold. Perhaps, it could be added as another app within the existing example? /cc @DamianEdwards too

michaelto20 commented 2 months ago

@IEvangelist, you are correct that the main changes are in the configs. Most of the config changes were in vite.config.ts and default.config.template. I think that adding this as another sample project is a good idea because pulling in environment variables into vite.config.ts is different from the typical Vite usage (i.e., VITE_). It took me a few hours to figure this out, and I believe it would be valuable to save others from the same headache.

Additionally, while there are many flavors of SPAs, Vite seems to be picking up a lot of steam over the last two years and I wondered if this work would help with adopting Aspire by those wanting to use Vite.

NatanelBarazani commented 2 months ago

With many new projects using Vite and Typescript with React, I struggled to find many examples or documentation on how to do that. I figured out the configuration and rewrote the weather sample app using Vite, Typescript, and React and would like to add that to the samples folder. Does this seem valuable and should I submit a PR for it?

Any chance you can make your repo public anyway?

IEvangelist commented 2 months ago

@michaelto20 - sure, I'd review the React + Vite addition to the existing SPA sample. I might end up adding Svelte as well, I suppose the more we can demonstrate for well-adopted frameworks the better.

michaelto20 commented 2 months ago

@NatanelBarazani I can't make the repo I was working on public as it is for my job but I've created a draft PR for review so @IEvangelist or @davidfowl if you'd like to review it and lend feedback I'd be happy to make any changes needed. Draft PR: #415

kcadduk commented 3 weeks ago

I just want to offer my Kudos. Having spent more than 2hrs looking for a solution. I managed to get my vite app working using your code here. +100 points. I hope your PR gets approved soon.

michaelto20 commented 2 weeks ago

@kcadduk Thanks for the shout out!