{"id":26337113,"url":"https://github.com/truewinter/astro-delete-unused-images","last_synced_at":"2025-10-16T00:31:50.312Z","repository":{"id":257464655,"uuid":"858399812","full_name":"TrueWinter/astro-delete-unused-images","owner":"TrueWinter","description":"Astro integration for use with static websites that deletes unused images from the dist directory.","archived":false,"fork":false,"pushed_at":"2024-09-16T20:54:37.000Z","size":148,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-09T13:39:54.115Z","etag":null,"topics":["astro-integration","withastro"],"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/TrueWinter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2024-09-16T20:35:44.000Z","updated_at":"2024-10-25T10:00:38.000Z","dependencies_parsed_at":"2024-09-16T23:47:25.749Z","dependency_job_id":"53f2a36c-15ed-447a-bcb3-4f98795e9378","html_url":"https://github.com/TrueWinter/astro-delete-unused-images","commit_stats":null,"previous_names":["truewinter/astro-delete-unused-images"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueWinter%2Fastro-delete-unused-images","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueWinter%2Fastro-delete-unused-images/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueWinter%2Fastro-delete-unused-images/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrueWinter%2Fastro-delete-unused-images/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TrueWinter","download_url":"https://codeload.github.com/TrueWinter/astro-delete-unused-images/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814895,"owners_count":20352038,"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":["astro-integration","withastro"],"created_at":"2025-03-16T02:17:45.717Z","updated_at":"2025-10-16T00:31:50.263Z","avatar_url":"https://github.com/TrueWinter.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# astro-delete-unused-images\n\n`astro-delete-unused-images` is an Astro integration for use with static websites that deletes unused images from the `dist` directory.\n\n![Image](https://cdn.truewinter.net/i/9cbd46.jpg)\n\n\u003e [!IMPORTANT]\n\u003e The image names must be detectable through very basic static analysis. For example: if the image is called `logo.BId0WUMc_1IXhhw.webp`, it will not be detected if you reference the image as `'logo.BId0WUMc' + '_1IXhhw.webp'`. Use the `filterImages` option to skip images referenced in this way to keep them in the build output.\n\n## Why?\n\nAstro keeps the original images in the `dist` directory just in case they're needed on the website. This isn't an issue for small websites, but for image-heavy websites (especially those that use HD images) this can take up a lot of additional storage space on production servers and increase CI/CD deploy times.\n\nRelevant issues:\n\n- https://github.com/withastro/astro/issues/11887\n- https://github.com/withastro/astro/issues/4961\n- https://github.com/withastro/astro/issues/8866\n\n## Installation\n\nEnsure that your output mode is set to `static` as this integration currently does not support other modes.\n\n### Automatic\n\nRun `npx astro add astro-delete-unused-images`.\n\n### Manual\n\nModify your `astro.config.mjs` file as follows:\n\n```js\nimport deleteUnusedImages from 'astro-delete-unused-images';\n\nexport default defineConfig({\n  integrations: [deleteUnusedImages()]\n});\n```\n\n## Configuration\n\nThe following options are available:\n\n```js\ninterface Opts {\n  /** If true, check if this image is referenced and remove it if it isn't */\n  filterImages?: (img: string) =\u003e boolean\n  /**\n   * If true, check this file for referenced images. Use caution with this option\n   * as the image will be deleted if it does not exist in any of the checked files.\n   */\n  checkFiles?: (file: string) =\u003e boolean\n  /** List of image file extensions. Default: `['.jpg', '.jpeg', '.png', '.webp', '.avif']` */\n  imageExtensions?: string[]\n  /** List of file extensions to check. Default: `['.html', '.css', '.js']` */\n  checkExtensions?: string[]\n  /** Don't delete unused images */\n  dryRun?: boolean\n}\n```\n\n### Example\n\n```js\ndeleteUnusedImages({\n  filterImages: (img) =\u003e !img.includes('skip')\n})\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruewinter%2Fastro-delete-unused-images","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftruewinter%2Fastro-delete-unused-images","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftruewinter%2Fastro-delete-unused-images/lists"}