Skip to content
Advertisement

Can we delete the Resources folder in Laravel after building the project?

In Laravel 9 where it uses Vite to bundle the js and css files, after running

npm run build

it created the bundled js and css files inside public/build folder.

Can we now delete the original js and css files that are created inside resources? or to upload the project to hosting without this resources folder?

Also, if I have other css/js files but not inside Resources folder, should I add them manually to the input array inside the vite.config.js file to get them compiled and bundled ?

Thanks

Advertisement

Answer

It depends on the assets you have in resources directory.

This directory can hold un-compiled front-end assets such as CSS or JavaScript – those will be bundled and available in public folder and served from there, therefore it’s safe to delete them on the shared hosting.

However, this directory can also hold backend assets like views, and those files will be read by Laravel directly on shared hosting. If you delete them, your Laravel application will crash.

Therefore, if the only assets you have in the folder are frontend ones that are bundled and served from public, it is safe to remove this directory, howevever there won’t be any performance improvement coming from that.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement