Created
January 6, 2019 11:20
-
-
Save khavari/38d7cd4fa7c247c30f8f64023c4949ac to your computer and use it in GitHub Desktop.
laravel-mix image minifier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install --save-dev imagemin-webpack-plugin copy-webpack-plugin imagemin-mozjpeg | |
const { 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: 'resources/assets/images', | |
to: 'img', // Laravel mix will place this in 'public/img' | |
}]), | |
new ImageminPlugin({ | |
test: /\.(jpe?g|png|gif|svg)$/i, | |
plugins: [ | |
imageminMozjpeg({ | |
quality: 80, | |
}) | |
] | |
}) | |
] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment