Importance of Vite folder structure
Hello, what does
Vite
provide with the uploaded structure? Why is it important/recommended to set up a Vite
project set-up, can't we just create files/folder as we need to?
6 Replies
npm create vite@latest moz-todo-react -- --template react
I just use this command I didn't really understand why we need to thoughBecause vite won't recognise it if you randomly create files. By default vite sees the index.html file in your root folder as the entry point.
Meaning it starts at index.html and sees if it is using other assets like the main.jsx you import into the html file using script tag. It uses that to figure out what code if should bundle/serve
You can configure different entry points but it's easier to just follow vite's default
The "public" folder is special. By default, it is used for static assets and will be served as if its contents are located at the root. You can disable that in the vite config and/or specify other folders if you want.
By default, built files go to "dist", but that can also be changed by changing the config file.
yep I see, by the way the
dist
folder is where optimized code goes?Well not optimised but more like minified and bundled code
Your multiple javascript files are bundled into one or two single ones, variable names are shortened etc to reduce the size
But yes dist is where your production build goes when you run the build command
That is where built code goes. Building usually optimizes, but that varies depending on the situation and configuration.