FilamentF
Filament14mo ago
simon

Minifying JS/CSS assets

I'm trying to work out how to minify my JS and CSS assets in production. I'm using the enlightn package and it flags a number of assets which aren't minified, including both core Filament resources such as public/css/filament/forms/forms.css and public/js/filament/filament/echo.js as well as plugin resources such as public/js/saade/filament-fullcalendar/components/filament-fullcalendar-alpine.js.

Running
npm run build
doesn't minify them and here is my Vite config:

import {
    defineConfig
} from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/css/app.css',
                'resources/js/app.js',
                'resources/css/filament/portal/theme.css'
            ],
            refresh: true,
        }),
    ],
    build: {
        minify: true,
        cssMinify: true,
    }
});

Strangely, all of the files are minified in my local environment when running
npm run build
, just not in my sandbox or production environment.

What am I missing?
Was this page helpful?