1/*
2 This code comes from Vincent Lab
3 And it has a video version linked here: https://www.youtube.com/watch?v=bmSOapQ5I78
4*/
5
6// Import dependencies
7const imagemin = require("imagemin");
8const imageminJpegtran = require("imagemin-jpegtran");
9const imageminPngquant = require("imagemin-pngquant");
10
11(async () => {
12
13 // Optimize the image size
14 const files = await imagemin(["original-images/*.{jpg,png}"], {
15 destination: "optimised-images",
16 plugins: [
17 imageminJpegtran(),
18 imageminPngquant()
19 ]
20 });
21
22 // Show amount of images optimize
23 console.log(`Optimized ${files.length} images`);
24
25})();