@sebaxba Easiest way to go about this would be to install a new copy of Laravel, install laravel/ui, then install Bootstrap scaffolding via the command
How to Install Bootstrap w/ Vite via Laravel/UI (easiest):
laravel new bootstrap-project
cd bootstrap-project
composer require laravel/ui
php artisan ui bootstrap
composer install
npm install
npm run dev
How to Install Bootstrap w/ Vite manually:
package.json
{
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"@popperjs/core": "^2.11.6",
"axios": "^1.1.2",
"bootstrap": "^5.2.3",
"laravel-vite-plugin": "^0.7.0",
"lodash": "^4.17.19",
"postcss": "^8.1.14",
"sass": "^1.56.1",
"vite": "^3.0.0"
}
}
Rename resources/css/app.css to resources/sass/app.scss (folder should be sAss, ext should be sCss)
vite.config.js
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: [
'resources/sass/app.scss',
'resources/js/app.js',
],
refresh: true,
}),
],
});
app.js (or bootstrap.js, do not confuse the package import w/ the Laravel default js files)
import 'bootstrap';
app.scss
@import 'bootstrap/scss/bootstrap';
app.blade.php - right above/before the closing </head> tag
@vite(['resources/sass/app.scss', 'resources/js/app.js'])
Then run:
npm update
composer install
npm run dev
Should be all you need.
Update: I just did this in a fresh project and it is working, just do what is listed here.