vite not recognizing app.js?

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.

Also, I see no app.js in my sources in dev tools, which I'm thinking should be in the js folder?
Solution
I have this in my blade layout file in the head:

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

Which layout? Did you override Filaments layout? You should use Filaments methods to add Javascript:
https://filamentphp.com/docs/3.x/support/assets#registering-javascript-files
Was this page helpful?