These instructions will guide you on how to add and install VueJs with Vite to a laravel project.
The following Requirements are assumed for this short guide:
1. Open a terminal in the root Laravel Directory.
2. install VueJs
npm install
npm install vue@next
npm install @vitejs/plugin-vue
code vit.config.js
3.Change the vite configs to the following code. Note that we create an alias called 'vue' to be used in main.js
vite.config.js
4. Create a man.js file and add the following code: $ code resources/js/main.js
main.js
5. Create App.vue
App.vue
mkdir resources/js/components
echo '<script></script><template><h1>App component</h1></template>' > resources/js/components/App.vue
code resources/js/components/App.vue
6. Open welcome.blade.php and change all the code to the following. $ code resources/views/welcome.blade.php
welcome.blade.php
7. Start the nodejs and php artisan server:
$ npm run dev
$ php artisan serve
8. Open in browser: http://127.0.0.1:8000
9. Done
10. Hope that helps.
Resource:/g/xampp8/htdocs/laravel/ForTesting_Purposes/laravel-for-testing