{"id":26329,"library":"rollup-plugin-img","title":"rollup-plugin-img","description":"Rollup plugin to import image files (PNG, JPG, GIF, SVG) as base64 data URIs or copied files, similar to Webpack's file-loader/url-loader. Current stable version 1.1.0. A single release exists; no updates since 2018. Differentiators: simple configuration, supports hash filenames, custom output path, and file size limit for base64 inlining. Alternative to rollup-plugin-image or rollup-plugin-url.","status":"maintenance","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/alwaysonlinetxm/rollup-plugin-img","tags":["javascript","rollup","rollup-plugin","image"],"install":[{"cmd":"npm install rollup-plugin-img","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-img","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-img","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for plugin execution.","package":"rollup","optional":false}],"imports":[{"note":"Plugin is ESM-only; use import syntax.","wrong":"const image = require('rollup-plugin-img').default","symbol":"default","correct":"import image from 'rollup-plugin-img'"},{"note":"Default export, not named.","wrong":"import { image } from 'rollup-plugin-img'","symbol":"image","correct":"import image from 'rollup-plugin-img'"}],"quickstart":{"code":"// rollup.config.js\nimport image from 'rollup-plugin-img';\n\nexport default {\n  input: 'src/index.js',\n  output: { file: 'dist/bundle.js', format: 'cjs' },\n  plugins: [\n    image({\n      output: 'dist/images',\n      limit: 10000,\n      hash: true\n    })\n  ]\n};","lang":"javascript","description":"Shows how to configure rollup-plugin-img with options for output directory, size limit, and hash filenames."},"warnings":[{"fix":"Always specify `output` option to control where copied files land.","message":"The `output` option is described as 'Required' in README but not enforced; missing it may cause files to be copied to the current working directory.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use a more robust plugin like rollup-plugin-url or rollup-plugin-file for production.","message":"When `hash: true`, hash is appended to the filename but the extension remains; no collision detection if two identical images are imported.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If using custom extensions, include SVG if needed: /.(png|jpg|jpeg|gif|svg)$/","message":"Plugin ignores SVGs by default if extensions override does not include them; default regex only matches PNG, JPG, JPEG, GIF, SVG.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use rollup-plugin-copy or the official Rollup asset mechanism for copying files.","message":"Files exceeding `limit` are copied to the output directory; the plugin does not emit them as assets properly for Rollup's asset handling.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider migrating to rollup-plugin-url (for base64) or @rollup/plugin-image for better maintenance.","message":"Package last updated in 2018; uses deprecated Rollup plugin API (e.g., `options` hook).","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Upgrade to Rollup 2.x with compatible plugin; or use rollup-plugin-url which supports modern API.","cause":"Plugin uses deprecated options hook which may not be supported in newer Rollup versions.","error":"Error: Invalid plugin hook: options"},{"fix":"Use `import image from 'rollup-plugin-img'` (no curly braces).","cause":"Incorrect import: using named import instead of default import.","error":"TypeError: image is not a function"},{"fix":"Ensure `image()` plugin is included in the plugins array and image extensions are covered.","cause":"Plugin not configured to handle image files; order of plugins matters.","error":"Could not resolve 'path/image.png' from 'src/index.js'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}