I am a software engineer with many years of backend experience. I have written highly scalable systems and provided my frontend colleagues the API's needed for them to fetch and save the data of our users. But up until now I was always missing the skills to create my own products end to end.
I’m currently learning...I decided that now was the time I would finally demystify web/mobile development for myself. I have dabbled with it over the years and have been discouraged by the sheer amount of knowledge I was lacking. But no more! I have found some great resources (like this place!) that is showing me the way.
Latest solutions
Vite + Typescript + React + Styled Components
#react#styled-components#typescript#vitePSubmitted over 1 year ago
Latest comments
- @klabruben3P@scottyroges
Hi @klabruben3!
Replying here from your comment on my solution for a different challenge.
I am by no means a Vite expert and I imagine this is probably not the preferred way for any kind of production site, but the way I got this to work was to do the following:
- On your local machine run
npm run build
. This will take all your react code and compile it to js the browse can understand. It will produce a folder calleddist
which has the compiled code. - In my
vite.config.js
I added thebase
property so that any urls to assets would be relative instead of absolute. (This might not be needed, but it was for me)
export default defineConfig({ base: "", // other configs });
3 In .gitignore I remove the line
dist
. This allows you to check in the dist folder when you commit you code. The annoying bit here is that to access your code you will need to go to {your handle}.github.io/{repo}/dist/index.htmlBecause this isn't a production site I felt this was good enough to get something that I could use for testing and to submit for a solution. But Vite actually has some documentation on how to do this properly using Github actions that is probably worth a read.
https://vitejs.dev/guide/static-deploy#github-pages
Hope this help!
- @scottyroges
Marked as helpful - On your local machine run