From 8d1f0d84fc380f19bfde8509c99264136eefb793 Mon Sep 17 00:00:00 2001 From: hosead6168 Date: Thu, 2 Sep 2021 19:55:01 -0500 Subject: [PATCH] feat(image): added image optimization --- config/imageOp.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 config/imageOp.js diff --git a/config/imageOp.js b/config/imageOp.js new file mode 100644 index 00000000..f070429d --- /dev/null +++ b/config/imageOp.js @@ -0,0 +1,21 @@ +import imagemin from 'imagemin'; +import imageminJpegtran from 'imagemin-jpegtran'; +import imageminPngquant from 'imagemin-pngquant'; + +const imageOp = (async () => { + try { + const files = await imagemin(['images/*.{jpg,png}'], { + destination: 'build/static/media', + plugins: [ + imageminJpegtran(), + imageminPngquant({ + quality: [0.6, 0.8] + }) + ] + }); + } catch (err) { + logger.error(err); + } +}) + +export { imageOp };