chiiya / laravel-mix-image-minimizer

Image minification for Laravel Mix
MIT License
6 stars 2 forks source link

minify svg with squoosh? #4

Closed codemonkeynorth closed 2 years ago

codemonkeynorth commented 2 years ago

Hi is it possible to minify (clean, remove comments etc) SVGs with squoosh or will I have to switch to the imagemin version?

alternatively do you have a suggestion for working with svg's separately to squoosh?

thanks

update.. I was hoping to do something like this but it doesn't work... the svg's don't get minified

    .images({
        // jpg, png etc
        implementation: 'squoosh',
        webp: true,
    },
    {
        // svg
        implementation: 'imagemin',
        options: {
            plugins: [
                [
                    "imagemin-svgo", 
                    {
                        plugins: ['preset-default']
                    }
                ]
            ]
        }
    })   
chiiya commented 2 years ago

For squoosh apparently there is no support yet. In your example you used an invalid configuration syntax combining squoosh and imagemin.

Have you tried just using imagemin instead of squoosh entirely?

mix.images({
  implementation: 'imagemin',
  webp: true,
});
codemonkeynorth commented 2 years ago

Hi, yes I ended up sticking with imagemin implementation as I couldn't get the normal laravel-mix-imagemin to work either (some issue with require & copy options)

This will do fine for now thanks