Vite plugin seems not to be reliable I made a fallback to mix which is more reliable, why always overcomplicating/changing things that worked ?...
Oct 16, 2022
5
Level 2
Vite bundle app.css but not app.js
Hello I'm struggling with Vite on a fresh laravel 9 project, I followed the documentation : I've added my resources/js/app.js in vite.config.js :
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: [
'resources/css/app.css',
'resources/js/app.js',
],
refresh: true,
}),
{
name: 'blade',
handleHotUpdate({ file, server }) {
if (file.endsWith('.blade.php')) {
server.ws.send({
type: 'full-reload',
path: '*',
});
}
},
}
],
});
and added
@vite('resources/css/app.css', 'resources/js/app.js')
in the blade file, unfortunately app.js is not avalaible, here is my resources/js/app.js
import './bootstrap';
import Alpine from 'alpinejs';
window.Alpine = Alpine;
Alpine.start();
I'm working on a mamp pro dev server with apache, npm 9.19.0, node 18.10. Naturally I made a npm run dev but I can't use Alpine, I don't see where is the problem. Thanks for your help. I noticed that in the console :
WebSocket connection to 'wss://localhost:5173/' failed:
Level 102
Vite takes an array, as the second argument is the path (not needed)
@vite(['resources/css/app.css', 'resources/js/app.js'])
1 like
Please or to participate in this conversation.