erbelion / tutorial-vite-plugin-laravel-purgecss

0 stars 0 forks source link

After build, css doesn't work #1

Closed tranvanhieu01012002 closed 5 days ago

tranvanhieu01012002 commented 6 days ago

I ran your example and it can reduce css size, but css doesn't work Build with laravel only image

Build with "@erbelion/vite-plugin-laravel-purgecss": "^0.3.2" image

this is vite.config.js

import { defineConfig } from "vite";
import laravel from "laravel-vite-plugin";
import purge from "@erbelion/vite-plugin-laravel-purgecss";

export default defineConfig({
    plugins: [
        laravel({
            input: ["resources/sass/app.scss", "resources/js/app.js"],
            refresh: true,
        }),
        purge(["resources/views/welcome.blade.php"])
    ],
});
erbelion commented 5 days ago

to make it work, you must either specify the paths to purge like this:

export default defineConfig({
    plugins: [
        laravel(...),
        purge({
            paths: ["resources/views/**/*.blade.php"]
        })
    ]
})

or don't specify the paths at all and let the plugin default it to resources/{js,views}/**/*.{blade.php,svelte,vue,html}:

export default defineConfig({
    plugins: [
        laravel(...),
        purge()
    ]
})

when trying out your way i realized, that path defaulting didn't work in 0.3.2. its now fixed as of 0.3.3