I’m using Laravel 10 + Vite to develop my app. But when I use Vite build, and load to my blade such as:
@vite('resources/js/app.js')
I got error 404 not found in Bootstrap. Here’s my app.js on /resources/js/app.js
:
import './bootstrap';
window.Echo.private('chat')
.listen('MessageSent', (e) => {
this.messages.push({
message: e.message.message,
user: e.user
});
});
And here’s my package.json :
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"watch": "vite build --watch",
"build-rtl": "rtlcss public/build/css/app.min.css"
},
"devDependencies": {
"@popperjs/core": "^2.11.6",
"axios": "^1.1.2",
"bootstrap": "^5.1.3",
"laravel-echo": "^1.15.3",
"laravel-vite-plugin": "^0.7.5",
"pusher-js": "^8.4.0-rc2",
"sass": "^1.56.1",
"vite": "^4.0.0"
},
"dependencies": {
"vite-plugin-static-copy": "^0.16.0",
"vue": "^3.4.19"
}
}
Any solution? thanks !
working Bootstrap script on my app.js with Laravel 10 + Vite
2
Answers
It's solved when I running
npm run dev
I another terminal too with
php artisan serve
ok, i suggested you use absolute path in your code.
for more info see this: link