{"_id":"@dmitrytavern/vite-imagetools","name":"@dmitrytavern/vite-imagetools","dist-tags":{"latest":"7.0.5"},"versions":{"7.0.5":{"name":"@dmitrytavern/vite-imagetools","description":"Load and transform images using a toolbox of import directives!","version":"7.0.5","type":"module","types":"dist/index.d.ts","exports":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"homepage":"https://github.com/JonasKruckenberg/imagetools/tree/main/packages/vite","author":{"name":"jkruckenberg","email":"iterpre@protonmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/JonasKruckenberg/imagetools.git"},"keywords":["resize-images","responsive-images","vite","image","vite-plugin"],"engines":{"node":">=18.0.0"},"dependencies":{"@rollup/pluginutils":"^5.0.5","sharp":"^0.33.4","imagetools-core":"npm:@dmitrytavern/imagetools-core@^7.0.2"},"devDependencies":{"@rollup/plugin-typescript":"^12.0.0","@types/jest-image-snapshot":"^6.4.0","@types/jsdom":"^21.1.1","@types/picomatch":"^3.0.0","@vitest/coverage-v8":"^3.0.7","jest-image-snapshot":"^6.4.0","jsdom":"^26.0.0","picomatch":"^4.0.0","rollup":"^4.22.4","sharp":"^0.33.1","tslib":"^2.6.1","typescript":"^5.1.6","vite":"^6.0.9","vitest":"^3.0.7","imagetools-core":"npm:@dmitrytavern/imagetools-core@^7.0.2"},"scripts":{"dev":"rollup -cw","build":"rollup -c","test":"vitest run","coverage":"vitest run --coverage"},"bugs":{"url":"https://github.com/JonasKruckenberg/imagetools/issues"},"_id":"@dmitrytavern/vite-imagetools@7.0.5","_integrity":"sha512-eAKiKMJVuDB/i5UW5B5ARpCQDKNz/0l7ql6tUBuSj/oWgAjmb5WwmzFuFIbEpWfSRJ0BPEyzdEH3rztubux+4Q==","_resolved":"/tmp/cc839d75ef0b7188801bcd9a0b65fc1c/dmitrytavern-vite-imagetools-7.0.5.tgz","_from":"file:dmitrytavern-vite-imagetools-7.0.5.tgz","_nodeVersion":"20.12.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-eAKiKMJVuDB/i5UW5B5ARpCQDKNz/0l7ql6tUBuSj/oWgAjmb5WwmzFuFIbEpWfSRJ0BPEyzdEH3rztubux+4Q==","shasum":"8e15f1a5cb81bfe6e10b95f43f15559c9b6b0994","tarball":"https://registry.npmjs.org/@dmitrytavern/vite-imagetools/-/vite-imagetools-7.0.5.tgz","fileCount":8,"unpackedSize":43344,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFgxzfqZsslvQ5sl/dg0NkKBc9HHhtCuGk67++J/IgKsAiAOcvRRvTURTLqt7r+sb5WhDDr8t0Z7hzJqA+5iPXDppQ=="}]},"_npmUser":{"name":"dmitry.tavern","email":"dmytrotraktirnyi@gmail.com"},"directories":{},"maintainers":[{"name":"dmitry.tavern","email":"dmytrotraktirnyi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/vite-imagetools_7.0.5_1742349264689_0.7218301563798337"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-19T01:54:24.554Z","7.0.5":"2025-03-19T01:54:24.870Z","modified":"2025-03-19T01:54:25.203Z"},"maintainers":[{"name":"dmitry.tavern","email":"dmytrotraktirnyi@gmail.com"}],"description":"Load and transform images using a toolbox of import directives!","homepage":"https://github.com/JonasKruckenberg/imagetools/tree/main/packages/vite","keywords":["resize-images","responsive-images","vite","image","vite-plugin"],"repository":{"type":"git","url":"git+https://github.com/JonasKruckenberg/imagetools.git"},"author":{"name":"jkruckenberg","email":"iterpre@protonmail.com"},"bugs":{"url":"https://github.com/JonasKruckenberg/imagetools/issues"},"license":"MIT","readme":"# vite-imagetools\n\n<!-- badges -->\n\n![npm (latest)](https://img.shields.io/npm/v/vite-imagetools)\n[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)\n[![codecov](https://codecov.io/gh/JonasKruckenberg/imagetools/branch/graph/badge.svg?token=bJrFBmuczA&flag=vite-imagetools)](https://codecov.io/gh/JonasKruckenberg/imagetools/)\n\nA toolbox of import [directives](../../docs/directives.md) for [Vite](https://github.com/vitejs/vite) that can transform\nyour image at compile-time. All of the image transformations are powered by [sharp](https://sharp.pixelplumbing.com).\n\n## Features\n\n- **🚀 Output modern formats**\n- **🖼 Resize Images**\n- **🔗 Easy Srcset generation**\n- **⚡️ Fast in development mode**\n- **🔒 Remove Image Metadata**\n- **🧩 Extensible**\n\n> [Read the docs to learn more!](https://github.com/JonasKruckenberg/imagetools/blob/main/docs/README.md)\n\n## Table of Contents\n\n- [Install](#install)\n- [Usage](#usage)\n- [Options](#options)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Install\n\n```\nnpm install --save-dev vite-imagetools\n```\n\n## Usage\n\n```ts\nimport { defineConfig } from 'vite'\nimport { imagetools } from 'vite-imagetools'\n\nexport default defineConfig({\n  plugins: [imagetools()]\n})\n```\n\n```js\nimport Image from 'example.jpg?w=400&h=300&format=webp'\n```\n\nYou can also import a directory of images using\n[Vite's `import.meta.glob` with its `query` option](https://vitejs.dev/guide/features.html#custom-queries).\n\n## Options\n\n### defaultDirectives\n\n• `Optional` **defaultDirectives**: `URLSearchParams | (url: URL) => URLSearchParams`\n\nThis option allows you to specify [directives](../../docs/directives.md) that should be applied _by default_ to every\nimage. You can also provide a function, in which case the function gets passed the asset ID and should return an object\nof [directives](../../docs/directives.md). This can be used to define all sorts of shorthands or presets.\n\n**`example`**\n\n```js\nimport { defineConfig } from 'vite'\nimport { imagetools } from 'vite-imagetools'\n\nexport default defineConfig({\n  plugins: [\n    imagetools({\n      defaultDirectives: (url) => {\n        if (url.searchParams.has('spotify')) {\n          return new URLSearchParams({\n            tint: 'ffaa22'\n          })\n        }\n        return new URLSearchParams()\n      }\n    })\n  ]\n})\n```\n\n---\n\n### exclude\n\n• **exclude**: `string | RegExp | (string | RegExp)[]`\n\nWhat paths to exclude when processing images. This defaults to the public dir to mirror Vite's behavior.\n\n**`default`** `'public\\/**\\/*'`\n\n---\n\n### include\n\n• **include**: `string | RegExp | (string | RegExp)[]`\n\nWhich paths to include when processing images.\n\n**`default`** `/^[^?]+\\.(heif|avif|jpeg|jpg|png|tiff|webp|gif)(\\?.*)?$/`\n\n---\n\n### removeMetadata\n\n• **removeMetadata**: `boolean`\n\nWether to remove potentially private metadata from the image, such as exif tags etc.\n\n**`default`** true\n\n---\n\n### extendOutputFormats\n\n▸ `Optional` **extendOutputFormats**(`builtins`): `Record`<`string`,\n[`OutputFormat`](../../docs/core/src/type-aliases/OutputFormat.md)\\>\n\nYou can use this option to extend the builtin list of output formats. This list will be merged with the builtin output\nformats before determining the format to use.\n\n**`default`** []\n\n#### Parameters\n\n| Name       | Type                                                                                    |\n| :--------- | :-------------------------------------------------------------------------------------- |\n| `builtins` | `Record`<`string`, [`OutputFormat`](../../docs/core/src/type-aliases/OutputFormat.md)\\> |\n\n#### Returns\n\n`Record`<`string`, [`OutputFormat`](../../docs/core/src/type-aliases/OutputFormat.md)\\>\n\n---\n\n### extendTransforms\n\n▸ `Optional` **extendTransforms**(`builtins`):\n[`TransformFactory`](../../docs/core/src/type-aliases/TransformFactory.md)<`Record`<`string`, `unknown`\\>\\>[]\n\nYou can use this option to extend the builtin list of import transforms. This list will be merged with the builtin\ntransforms before applying them to the input image.\n\n**`default`** []\n\n#### Parameters\n\n| Name       | Type                                                                                                          |\n| :--------- | :------------------------------------------------------------------------------------------------------------ |\n| `builtins` | [`TransformFactory`](../../docs/core/src/type-aliases/TransformFactory.md)<`Record`<`string`, `unknown`\\>\\>[] |\n\n#### Returns\n\n[`TransformFactory`](../../docs/core/src/type-aliases/TransformFactory.md)<`Record`<`string`, `unknown`\\>\\>[]\n\n---\n\n### resolveConfigs\n\n• `Optional` **resolveConfigs**: (`entries`: `[string, string[]][]`, `outputFormats`: `Record`<`string`,\n[`OutputFormat`](../core/src/README.md#outputformat)\\>) => `Record<string, string | string[]>[]`\n\n#### Type declaration\n\n▸ (`entries`, `outputFormats`): `Record<string, string | string[]>[]`\n\nThis function builds up all possible combinations the given entries can be combined an returns it as an array of objects\nthat can be given to a the transforms.\n\n##### Parameters\n\n| Name            | Type                                                                      | Description               |\n| :-------------- | :------------------------------------------------------------------------ | :------------------------ |\n| `entries`       | `[string, string[]][]`                                                    | The url parameter entries |\n| `outputFormats` | `Record`<`string`, [`OutputFormat`](../core/src/README.md#outputformat)\\> | -                         |\n\n##### Returns\n\n`Record<string, string | string[]>[]`\n\nAn array of directive options\n\n## Contributing\n\nFeel free to dive in! [Open an issue](https://github.com/JonasKruckenberg/imagetools/issues/new) or submit PRs! All\ninformation to get you started hacking on imagetools is in [CONTRIBUTING.md](../../CONTRIBUTING.md)!\n\n## License\n\n[MIT © Jonas Kruckenberg.](./LICENSE)\n","readmeFilename":"README.md","_rev":"1-ff5537dfa0721f3697f4d82d5c339ee5"}