I am using vite in laravel. I have imported 5 js files in app.js. after npm run dev. At page refresh it load 5 of them in network of browser plus app.js loaded too. I think purpose of vite is too load just one file app.js. and one file of app.css because of it optimization the loading of asset file. Right ?
@jlrdw I have another question. Should I use asset() to load my images, or should I use Vite::asset()?
Will Vite::asset() optimize my images at loading time? If yes, then I'll use Vite::asset(). if not than it's okay to use asset(), right?
Second question:
After the build, Vite copy all my assets from 'resources/assets' to 'public/build/assets' Now we have assets in two different locations. How do I delete them from 'resources/assets'? Is there a command for it, or do I have to do it manually?
Or do we even need to delete them, since we are now in a production environment?
@abdulrehman176617 The reason for running npm run dev during development is hot module replacement (HMR). That means any change you make is immediately reflected on your web page; no asset bundling (or even a page reload) is needed. You only want to bundle the assets when you're deploying to production.
After the build, Vite copy all my assets from 'resources/assets' to 'public/build/assets' Now we have assets in two different locations. How do I delete them from 'resources/assets'? Is there a command for it, or do I have to do it manually?
You don't delete them. Public assets are built from your resources. If you delete them, you can no longer rebuild.