Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

mfjordvald/laravel-mix-image-minimizer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Mix Image Minimizer

Latest Version on NPM npm Software License

This extension adds support for image-minimizer-webpack-plugin to Laravel Mix.

Installation

Install the extension and the implementation of your choice. It's recommended to use squoosh since imagemin is not maintained anymore.

# Using squoosh
npm i -D @chiiya/laravel-mix-image-minimizer @squoosh/lib
# Using imagemin
npm i -D @chiiya/laravel-mix-image-minimizer imagemin imagemin-gifsicle imagemin-mozjpeg imagemin-pngquant imagemin-svgo imagemin-webp

Usage

Require the extension inside your webpack.mix.js and use it like so:

const mix = require('laravel-mix');
require('@chiiya/laravel-mix-image-minimizer');

mix.images({
  webp: true,
});

Options

Name Type Default Description
implementation string squoosh squoosh or imagemin, see image-minimizer-webpack-plugin docs
patterns Array<Object> [{ from: "**/*", to: "images", context: "resources/images" }] pattern option as supported by the copy-webpack-plugin
webp Boolean false If enabled, additional webp versions of all images will be generated
options Object undefined for squoosh, { plugins: ["imagemin-gifsicle", "imagemin-mozjpeg", "imagemin-pngquant", "imagemin-svgo"] } for imagemin Custom configuration for squoosh or imagemin
copyOptions Object { patterns: options.patterns } Additional configuration for the copy-webpack-plugin
webpOptions Object { encodeOptions: { webp: { quality: 90 }}} for squoosh, { plugins: ["imagemin-webp"] } for imagemin Custom squoosh or imagemin configuration for generating webp images

About

Image minification for Laravel Mix

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%