Skip to content

Instantly share code, notes, and snippets.

@rjriel
Last active September 1, 2020 13:58
Show Gist options
  • Save rjriel/71d60d425e994515cd66bb6e08e4fa27 to your computer and use it in GitHub Desktop.
Save rjriel/71d60d425e994515cd66bb6e08e4fa27 to your computer and use it in GitHub Desktop.
const imagemin = require('imagemin'), // The imagemin module.
webp = require('imagemin-webp'), // imagemin's WebP plugin.
outputFolder = './src/assets', // Output folder
PNGImages = './src/assets/*.png', // PNG images
JPEGImages = './src/assets/*.jpg' // JPEG images
imagemin([PNGImages], outputFolder, {
plugins: [
webp({
lossless: true // Losslessly encode images
})
]
})
imagemin([JPEGImages], outputFolder, {
plugins: [
webp({
quality: 65 // Quality setting from 0 to 100
})
]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment