Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lokisapocalypse's avatar

Adding static assets

Hello all. I'm pretty new to Laravel and am setting up a site with laravel 9. I set up a pretty simple site and followed the instructions for using vite to manage my css and js files. When I run npm run dev, the site works as expected. But when I run npm run build, I get a bunch of console errors like they were compiled in a different order. Things like libraries not knowing what jquery is all of a sudden.

Here is my vite config:

import { defineConfig } from 'vite';

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/css/app.css',
                'resources/js/app.js',
                'resources/css/plugins.css',
                'resources/css/style.css',
                'resources/js/popper.min.js',
                'resources/js/bootstrap.min.js',
                'resources/js/scrollIt.min.js',
                'resources/js/animated.headline.js',
                'resources/js/jquery.appear.js',
                'resources/js/jquery.count.min.js',
                'resources/js/owl.carousel.min.js',
                'resources/js/jquery.magnific-popup.min.js',
                'resources/js/jquery.stellar.min.js',
                'resources/js/isotope.pkgd.min.js',
                'resources/js/particles.min.js',
                'resources/js/countdown.js',
                'resources/js/granim.min.js',
                'resources/js/map.js',
                'resources/js/scripts.js',
                'resources/js/mailform/jquery.form.min.js',
                'resources/js/mailform/jquery.rd-mailform.min.c.js',
                'resources/img/apple-touch-icon-57x57.png',
                'resources/img/favicon.png',
                'resources/img/apple-touch-icon-72x72.png',
                'resources/img/apple-touch-icon-114x114.png',
                'resources/img/doctors.jpeg',
                'resources/js/jquery.min.js',
            ],
            refresh: true,
        }),
    ],
});

I've tried reordering the files both in the blade template and in the vite config and neither seems to make much of a difference.

0 likes
2 replies

Please or to participate in this conversation.