Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

imagemin-webp-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imagemin-webp-webpack-plugin

Webpack plugin which converts images to the WebP format while also keeping the original files.

  • 3.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.6K
decreased by-4.84%
Maintainers
1
Weekly downloads
 
Created
Source

imagemin-webp-webpack-plugin

Webpack plugin which converts images to the WebP format while also keeping the original files. Built for webpack 4 but should work in previous versions as well.

It uses imagemin and imagemin-webp under the hood.

Motivation

Although WebP images are not currently supported in all browsers, they are at least 25% smaller than PNG's or JPEG's. So, certain users can get a much better experience.

Check the support tables on Can I use

Installation

$ npm install imagemin-webp-webpack-plugin --save-dev

Usage

In order to use this plugin, add it to your webpack config.

const ImageminWebpWebpackPlugin= require("imagemin-webp-webpack-plugin");

module.exports = {
    plugins: [new ImageminWebpWebpackPlugin()]
};

⚠ Keep in mind that plugin order matters, so usually you'd want to put it last.

API

new ImageminWebpWebpackPlugin( [settings] );

settings

Type: Object

Default:

{
  config: [{
    test: /\.(jpe?g|png)/,
    options: {
      quality:  75
    }
  }],
  overrideExtension: true,
  detailedLogs: false,
  silent: false,
  strict: true
}
config

Type Array<Object: {test, options} >

The main config of the plugin which controls how different file types are converted. Each item in the array is an object with 2 properties:

  • test - a RegExp selecting just certain images
  • options -the converting options for the images that pass the above RegExp

⚠ The options object is actually the same one from the imagemin-webp plugin so check their documentation for the available settings.

overrideExtension

Type: boolean
Default: true

By default the plugin will override the original file extension, so you will get: image.png -> image.webp

In case you want to concat '.webp' at the end of the file name, set the config value to false. Ex: image.png -> image.png.webp. It may be useful when using nginx or similar to serve .webp files, if http-accept header contains webp just add a suffix to the requested image.

detailedLogs

Type: boolean
Default: false

By default the plugin will print to the console

  1. the total number of megabytes saved by the webp images compared to the original ones
  2. the number of images that failed being converted

This options tells the plugin to also log the size difference per converted image and the names of the images that failed conversion.

silent

Type: boolean
Default: false

In case you don't want anything printed to the console set this option to false. This will override the detailedLogs option.

strict

Type: boolean
Default: true

By default the webpack build will fail if any of the images that match your RegExps fail the conversion.

This option tells the plugin to not crash the build and keep going :)


Made with ❤ by Pava

Keywords

FAQs

Package last updated on 19 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc