{"id":21533134,"url":"https://github.com/iampava/imagemin-webp-webpack-plugin","last_synced_at":"2025-04-06T02:11:09.146Z","repository":{"id":37740758,"uuid":"145561506","full_name":"iampava/imagemin-webp-webpack-plugin","owner":"iampava","description":"Webpack plugin which converts images to the WebP format while also keeping the original files.","archived":false,"fork":false,"pushed_at":"2023-03-06T20:47:46.000Z","size":5303,"stargazers_count":112,"open_issues_count":41,"forks_count":26,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T01:09:00.096Z","etag":null,"topics":["imagemin","imagemin-webp","images","webp","webpack","webpack-plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iampava.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-21T12:33:14.000Z","updated_at":"2025-01-16T17:02:15.000Z","dependencies_parsed_at":"2024-06-18T13:56:23.175Z","dependency_job_id":"f6da3554-c9ad-40e9-bd8f-227aa70f7e73","html_url":"https://github.com/iampava/imagemin-webp-webpack-plugin","commit_stats":{"total_commits":51,"total_committers":9,"mean_commits":5.666666666666667,"dds":0.6274509803921569,"last_synced_commit":"07a185d3d1a87bfc0f915bc77f6f9eb0cab07d5c"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iampava%2Fimagemin-webp-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iampava%2Fimagemin-webp-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iampava%2Fimagemin-webp-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iampava%2Fimagemin-webp-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iampava","download_url":"https://codeload.github.com/iampava/imagemin-webp-webpack-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423515,"owners_count":20936626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["imagemin","imagemin-webp","images","webp","webpack","webpack-plugin"],"created_at":"2024-11-24T02:23:55.160Z","updated_at":"2025-04-06T02:11:09.095Z","avatar_url":"https://github.com/iampava.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# imagemin-webp-webpack-plugin\n\n \n**Webpack** plugin which converts images to the [WebP](https://developers.google.com/speed/webp/) format while also keeping the original files. Compatible with **webpack 5**, **webpack 4** and previous versions as well.\n\n\nIt uses [imagemin](https://www.npmjs.com/package/imagemin), [imagemin-webp](https://www.npmjs.com/package/imagemin-webp) and [imagemin-gif2webp](https://www.npmjs.com/package/imagemin-gif2webp) under the hood.\n\n \n## Motivation\n\nAlthough 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. WebP also supports Gif-like functionality so this plugin also works for GIF images.\n\nCheck the support tables on [Can I use](https://caniuse.com/#feat=webp)\n\n\n## Installation\n\n  \n\n```bash\n$ npm install imagemin-webp-webpack-plugin --save-dev\n```\n\n  \n\n## Usage\n\n  \n\nIn order to use this plugin, add it to your **webpack config**.\n\n  \n\n```js\nconst ImageminWebpWebpackPlugin= require(\"imagemin-webp-webpack-plugin\");\n\nmodule.exports = {\n    plugins: [new ImageminWebpWebpackPlugin()]\n};\n```\n⚠ Keep in mind that plugin order matters, so usually you'd want to put it last.\n  \n  \n\n## API\n\n  \n\n### ```new ImageminWebpWebpackPlugin( [settings] );```\n\n  \n\n### settings\n\n  \n\nType: `Object`\u003cbr/\u003e\n\nDefault:\n\n```js\n{\n  config: [{\n    test: /\\.(jpe?g|png)/,\n    options: {\n      quality:  75\n    }\n  }],\n  overrideExtension: true,\n  detailedLogs: false,\n  silent: false,\n  strict: true\n}\n```\n\n#### config\nType ```Array\u003cObject: {test, options} \u003e```\n\n\nThe main config of the plugin which controls how different file types are converted. Each item in the array is an object with 2 properties:\n\n* **test** - a RegExp selecting just certain images. Supported image formats are **JPG**, **PNG** and **GIF**.\n* **options** -the converting options for the images that pass the above RegExp\n\n⚠ The **options** object is actually the same one from the [imagemin-webp](https://www.npmjs.com/package/imagemin-webp) plugin so check their documentation for the available settings.\n\n#### overrideExtension\n\nType: `boolean`\u003cbr\u003e\nDefault: `true`\n\nBy default the plugin will override the original file extension, so you will get: `image.png` -\u003e `image.webp`\n\nIn case you want to concat '.webp' at the end of the file name, set the config value to false. Ex: `image.png` -\u003e `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. \n\n#### detailedLogs\n\nType: `boolean`\u003cbr\u003e\nDefault: `false`\n\nBy default the plugin will print to the console\n\n1. the total number of megabytes saved by the webp images compared to the original ones\n2. the number of images that failed being converted\n\nThis options tells the plugin to also log the size difference per converted image and the names of the images that failed conversion.\n\n#### silent\n\nType: `boolean`\u003cbr\u003e\nDefault: `false`\n\nIn case you don't want anything printed to the console set this option to false. This will override the `detailedLogs` option. \u003cbr\u003e\n\n#### strict\n\nType: `boolean`\u003cbr\u003e\nDefault: `true`\n\nBy default the webpack build will fail if any of the images that match your RegExps fail the conversion.\n\nThis option tells the plugin to not crash the build and keep going :)\n\n## Compatibility \u0026 known issues\n\nRecently we updated this plugin to make it compatible with **webpack 5**. Originally it was built for **webpack 4** and earlier versions, so I expect it would be compatible no matter the project :)\n\nHowever, there is a known issue with `css-loader@latest` where importing `.webp` images will fail because they don't exist prior the build time. For example this CSS code:\n\n```\nbody {\n  backgrund-image: url('/assets/cover.webp')\n}\n```\n\nwill fail since initially only `cover.jpg` exists, and `cover.webp` is created dynamically by this Plugin. \n\nPlease read some more about this [here](https://github.com/iampava/imagemin-webp-webpack-plugin/issues/56) and upvote [the issue](https://github.com/iampava/imagemin-webp-webpack-plugin/issues/56) if you want me to implement a fix :D\n\n\n## Other mentions\n\n* it doesn't re-convert images while developing\n* if you change the actual image but keep the name, somehow `webpack` is smart enough to detect this and it will re-convert just that image\n* there are  2 projects used to test if/how this plugin works in **webpack 5** and **webpack 4**. The projects are: [test-project](https://github.com/iampava/imagemin-webp-webpack-plugin/tree/master/test-project) and [test-project-webpack5](https://github.com/iampava/imagemin-webp-webpack-plugin/tree/master/test-project-webpack5).\n\n\u003chr/\u003e\n\n\u003cp align=\"center\"\u003e Made with ❤ by \u003ca href=\"https://iampava.com\"\u003e Pava \u003c/a\u003e\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiampava%2Fimagemin-webp-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiampava%2Fimagemin-webp-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiampava%2Fimagemin-webp-webpack-plugin/lists"}