{"id":22069,"library":"rollup-plugin-image-file","title":"rollup-plugin-image-files","description":"Rollup plugin that copies image files to the output directory and returns a require()-compatible path, instead of inlining base64. This fork (v1.0.2) builds on the original with additional features. It targets bundling libraries for React Native and similar environments where base64 inlining is undesirable. Version 1.0.2 is the current stable release, but development appears sparse (no recent commits). Key differentiator from rollup-plugin-image: writes files to disk rather than embedding them as base64.","status":"maintenance","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/bspaulding/rollup-plugin-image-files","tags":["javascript","rollup-plugin","image","typescript"],"install":[{"cmd":"npm install rollup-plugin-image-file","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-image-file","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-image-file","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: the plugin hooks into Rollup's build system.","package":"rollup","optional":false}],"imports":[{"note":"The plugin exports a default function; named import will be undefined.","wrong":"import { images } from 'rollup-plugin-image-files'","symbol":"default (images)","correct":"import images from 'rollup-plugin-image-files'"},{"note":"CommonJS require returns the default export as a whole.","wrong":"const { images } = require('rollup-plugin-image-files')","symbol":"require (CJS)","correct":"const images = require('rollup-plugin-image-files')"},{"note":"Types are shipped; no separate type import needed.","wrong":null,"symbol":"TypeScript types","correct":"import images from 'rollup-plugin-image-files'"}],"quickstart":{"code":"// rollup.config.js\nimport images from 'rollup-plugin-image-files';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'cjs'\n  },\n  plugins: [images()]\n};\n\n// src/index.js\nimport logo from './logo.png';\nconsole.log(logo); // e.g., './dist/logo.png'","lang":"javascript","description":"Shows basic setup: import the plugin, add to Rollup config, and use an image import in source."},"warnings":[{"fix":"Ensure images are placed in a directory relative to the output, or use a custom copy function.","message":"Image files must be in the same directory as the output bundle or relative paths break.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use a dedicated plugin for SVG or other formats.","message":"The plugin may not handle SVG or non-raster images well; only tested with PNG/JPEG.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider using rollup-plugin-image if base64 inlining is acceptable.","message":"The original package name 'rollup-plugin-image-files' is a fork; the underlying plugin 'rollup-plugin-image' is more maintained.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add the plugin to rollup config and ensure the image exists at the specified path.","cause":"Image path is relative to source file, but Rollup cannot resolve non-JS files without plugin.","error":"Error: Could not resolve '../path/to/image.png' from 'src/index.js'"},{"fix":"Use default import: import images from 'rollup-plugin-image-files'","cause":"Named import used instead of default import.","error":"TypeError: images is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}