Answer the question
In order to leave comments, you need to log in
How to optimize images in laravel mix?
I decided to try an alternative to gulp and work with Laravel Mix.
In office The documentation for Laravel Mix explains everything quite clearly, however, I had difficulties with optimizing images.
My assembly code:
let mix = require('laravel-mix');
const ImageminPlugin = require('imagemin-webpack-plugin').default;
const CopyWebpackPlugin = require('copy-webpack-plugin');
const imageminMozjpeg = require('imagemin-mozjpeg');
mix.webpackConfig({
plugins: [
new CopyWebpackPlugin([{
from: 'src/img',
to: 'build/img',
}]),
new ImageminPlugin({
test: /\.(jpe?g|png|gif|svg)$/i,
plugins: [
imageminMozjpeg({
quality: 80,
})
]
})
]
});
ValidationError: Invalid options object. Copy Plugin has been initialized using an opti
ons object that does not match the API schema.
Answer the question
In order to leave comments, you need to log in
It's written the same: wrong CopyWebpackPlugin plugin settings object.
Check out the documentation https://webpack.js.org/plugins/copy-webpack-plugin/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question