chiiya / laravel-mix-image-minimizer Goto Github PK
View Code? Open in Web Editor NEWImage minification for Laravel Mix
License: MIT License
Image minification for Laravel Mix
License: MIT License
Hello there,
I have just discovered your repo, but I can make it work at 100% on my project. I think I miss something but I dont know what.
In my webpack.mix.js, I have:
// Laravel Mix
const mix = require('laravel-mix');
// https://www.npmjs.com/package/@chiiya/laravel-mix-image-minimizer
require('@chiiya/laravel-mix-image-minimizer');
// Options for Laravel Mix
// https://laravel-mix.com/docs/4.0/options
mix.options({
postCss: [require('autoprefixer')],
cssNano: {
discardComments: {removeAll: true},
}
}).setPublicPath('public');
mix.setResourceRoot('../..');
mix.images({
implementation: 'squoosh',
patterns: [{ from: "resources/assets/images", to: "assets/images" }],
webp: true,
webpOptions: { encodeOptions: { webp: { quality: 90 }}}
});
// ...
The images are copied from /resources/assets/images to /public/assets/images so no problem with this.
But, they have the same weight so I guess the images in /public/assets/images are not optimised/compressed after a npm run dev.
Any idea why?
Thank you for your help
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']
}
]
]
}
})
Hi,
When I'm running mix production I'm getting the following warning:
WARNING in "imageminMinify" function do not support generate to "jpg" from "dist/images/web/Home_header.jpeg". Please use "imageminGenerate" function.
This is my implementation of the plugin:
mix.images( {
webp: true,
implementation: 'imagemin',
patterns: [
{ from: "**/*", to: "dist/images", context: "assets/images" }
]
} )
Do you have a clue how this warning can be solved (apart from changing the original file to jpg :))?
Hi,
Thanks for creating this plugin! I've got an request to improve the handling of webp images. I'm using webp images in combination with a rewrite in htaccess. To make this work the webp extension needs to be appended to the original file name, including the original extension. Can you add an option for this?
I found this solution in another plugin: https://github.com/iampava/imagemin-webp-webpack-plugin#overrideextension, which might work great!
Thanks,
Jorn
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.