Laravel Vite doesn't seem to find or bundle app.js file

162 Views Asked by At

I'm using Laravel 10 in a Filament project with vite. I have pretty much the stock vite.config.js file:

import { defineConfig } from 'vite'
import laravel, { refreshPaths } from 'laravel-vite-plugin'

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/css/app.css',
                'resources/js/app.js',
                'resources/css/filament/app/theme.css'
            ],
            refresh: [
                ...refreshPaths,
                'app/Filament/**',
                'app/Forms/Components/**',
                'app/Livewire/**',
                'app/Infolists/Components/**',
                'app/Providers/Filament/**',
                'app/Tables/Columns/**',
            ],
        }),
    ],
})

I have this in my blade layout file in the head:

@vite(['resources/css/app.css', 'resources/js/app.js'])

In my resources/js/app.js file I have this:

console.log('test');
import JSConfetti from 'js-confetti';

const jsConfetti = new JSConfetti();
window.jsConfetti = jsConfetti;

console.log('jsConfetti is set', window.jsConfetti);

I've run npm run build, but I don't even get the simple "test" message from the console.log statement in app.js. It almost seems like vite isn't loading the app.js file at all. I should at the very least see the "test" message from app.js, right?

I upgraded the laravel-vite plugin to 1.0.1 and upgraded vite to 5.0.0, but that hasn't resolved it either. I've cleared the cache and hard refreshed. I've verified that jsConfetti is in my node_modules folder.

UPDATE

Here's what I see in the sources tab in dev tools:

enter image description here

0

There are 0 best solutions below