{"id":13774587,"url":"https://github.com/malchata/rollup-plugin-imagemin","last_synced_at":"2025-04-14T16:09:46.839Z","repository":{"id":33689628,"uuid":"160684986","full_name":"malchata/rollup-plugin-imagemin","owner":"malchata","description":"Imagemin meets Rollup!","archived":false,"fork":false,"pushed_at":"2023-01-07T04:00:50.000Z","size":1131,"stargazers_count":25,"open_issues_count":10,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-23T19:11:27.157Z","etag":null,"topics":["image-optimisation","image-optimization","imagemin","javascript","rollup-plugin","rollupjs","web-performance","webperf","webperformance"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/malchata.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-06T14:18:06.000Z","updated_at":"2023-10-18T05:55:49.000Z","dependencies_parsed_at":"2023-01-15T02:04:51.580Z","dependency_job_id":null,"html_url":"https://github.com/malchata/rollup-plugin-imagemin","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malchata%2Frollup-plugin-imagemin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malchata%2Frollup-plugin-imagemin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malchata%2Frollup-plugin-imagemin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malchata%2Frollup-plugin-imagemin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/malchata","download_url":"https://codeload.github.com/malchata/rollup-plugin-imagemin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240062526,"owners_count":19742218,"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":["image-optimisation","image-optimization","imagemin","javascript","rollup-plugin","rollupjs","web-performance","webperf","webperformance"],"created_at":"2024-08-03T17:01:28.333Z","updated_at":"2025-02-25T17:30:53.931Z","avatar_url":"https://github.com/malchata.png","language":"JavaScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Other File Imports"],"readme":"# rollup-plugin-imagemin\n\n`rollup-plugin-imagemin` is a Rollup plugin that uses [`imagemin`](https://github.com/imagemin/imagemin) to optimize images in your Rollup build. If you've used `imagemin` on any other platform before, this will feel familiar to you.\n\n## Install\n\n```\nnpm i rollup-plugin-imagemin --save-dev\n```\n\n## Usage\n\n```javascript\n// rollup.config.js\nimport { imagemin } from \"rollup-plugin-imagemin\";\n\nexport default {\n  plugins: [\n    imagemin()\n  ],\n  input: \"src/index.js\"\n  output: {\n    format: \"esm\",\n    file: \"./dist/index.js\"\n  }\n};\n\n// src/index.js\nimport someImage from \"./some-image.png\"; // \u003c-- With the above config, this should output an optimized PNG to the dist folder.\n```\n\n## Options\n\n`rollup-plugin-imagemin` has number of useful options to help you tune your builds to your liking:\n\n- `disable` (default: `false`): Disable all optimizations and output unoptimized images. Useful for speedier development builds.\n- `verbose` (default: `false`): Enables verbose logging, such as optimization gains.\n- `emitFiles` (default: `true`): Whether to emit files. Could be useful for server side builds. Be aware that unless `disable` is set to `true`, images will still be optimized in memory, but will not be written to disk.\n- `hashLength` (default: `16`): The length of hashes used in asset filenames.\n- `include` (default: `\"**/*.{svg,png,jpg,jpeg,gif}\"`): File glob pattern of assets to be processed by `rollup-plugin-imagemin`.\n- `exclude` (default: `\"\"`): File glob pattern of assets to _not_ be processed by `rollup-plugin-imagemin`. The pattern defined by `exclude` is applied after the value of the `include` option pattern.\n- `fileName` (default: `\"[name]-[hash][extname]\"`): The output filename pattern of images optimized by `rollup-plugin-imagemin`. The pattern includes the following tokens:\n  - `[name]`: The basename of the input file.\n  - `[hash]`: The has of the input file.\n  - `[extname]`: The extension of the input file.\n- `publicPath` (default: `\"\"`): A folder for where to put optimized assets. Use this to separate your images into a separate folder.\n- `preserveTree` (default: `false`): If `true`, preserve directory structure relative to `process.cwd()`.\nCan also be a path specifying root from where directory structure should be preserved.\n- `gifsicle`: (default: `{ optimizationLevel: 3 }`): Settings to merge with default, to pass to [`imagemin-gifsicle`](https://www.npmjs.com/package/imagemin-gifsicle).\n- `jpegtran` (default: `{ progressive: true }`): Settings to merge with default, to pass to [`imagemin-jpegtran`](https://www.npmjs.com/package/imagemin-jpegtran).\n- `pngquant`: (default: `{ speed: 1, strip: true }`): Settings to merge with default, to pass to [`imagemin-pngquant`](https://www.npmjs.com/package/imagemin-pngquant).\n- `svgo`: (default: `{ precision: 1, multipass: true }`): Settings to merge with default, to pass to [`imagemin-svgo`](https://www.npmjs.com/package/imagemin-svgo).\n- `plugins`: object with *plugin names* as keys and [plugins](https://www.npmjs.com/search?q=keywords:imageminplugin) as value to pass to `imagemin`. By default, `{gifsicle: 'imagemin-gifsicle', jpegtran: 'imagemin-jpegtran', pngquant: 'imagemin-pngquant', svgo: 'imagemin-svgo'}` are used. Each plugin\nfunction must be a factory, taking the plugin's config (the object at `options[pluginName]`, merged with defaults), and returning an imagemin buffer transformer.\n\n## Using custom plugins\n\nYou can use custom plugins the following way:\n\n```javascript\n// rollup.config.js\nimport imagemin from \"rollup-plugin-imagemin\";\nimport myCustomPlugin from \"imagemin-my-custom-plugin\";\n\nexport default {\n  plugins: [\n    imagemin({\n        myCustomPlugin: {\n            // Config to pass to `myCustomPlugin`'s factory\n        },\n        plugins: {\n            myCustomPlugin,\n        }\n    })\n  ],\n  input: \"src/index.js\"\n  output: {\n    format: \"esm\",\n    file: \"./dist/index.js\"\n  }\n};\n```\n\n## Contributing\n\nPlease read the contributing guidelines in [`CONTRIBUTING.md`](https://github.com/malchata/rollup-plugin-imagemin/blob/master/CONTRIBUTING.md).\n\n## Special thanks\n\nThis is my first Rollup plugin. As such, I drew extensive help from the Rollup documentation, but also from the [`rollup-plugin-url`](https://github.com/rollup/rollup-plugin-url) and [`rollup-plugin-image`](https://github.com/rollup/rollup-plugin-image) source code. If anything in the plugin looks familiar to either of those two, it's no coincidence, and I owe a lot to the authors of those plugins for inspiration and guidance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalchata%2Frollup-plugin-imagemin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmalchata%2Frollup-plugin-imagemin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalchata%2Frollup-plugin-imagemin/lists"}