{"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,"search_vec":"'/url-loader':29 '1.1.0':33 '2018':41 'altern':58 'base64':16,56 'configur':44 'copi':20 'current':30 'custom':48 'data':17 'differenti':42 'exist':37 'file':10,21,27,52 'file-load':26 'filenam':47 'gif':13 'hash':46 'imag':9,63,74 'img':4 'import':8 'inlin':57 'javascript':69 'jpg':12 'limit':54 'loader':28 'output':49 'path':50 'plugin':3,6,62,67,73 'png':11 'releas':36 'rollup':2,5,61,66,70,72 'rollup-plugin':71 'rollup-plugin-imag':60 'rollup-plugin-img':1 'rollup-plugin-url':65 'similar':22 'simpl':43 'sinc':40 'singl':35 'size':53 'stabl':31 'support':45 'svg':14 'updat':39 'uri':18 'url':68 'version':32 'webpack':24","created_at":"2026-05-01T13:49:25.114892+00:00","updated_at":"2026-05-01T13:49:25.114892+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/alwaysonlinetxm/rollup-plugin-img","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/rollup-plugin-img","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-01","next_check":"2026-07-30","install_tag":null}}