{"id":22070,"library":"rollup-plugin-image-files","title":"rollup-plugin-image-files","description":"Rollup plugin that copies image files to the output directory and replaces imports with require() references. Version 1.4.2, likely low maintenance cadence. Unlike rollup-plugin-image which inlines base64, this preserves binary files, making it suitable for React Native libraries where images must be bundled separately. Limited scope and niche use case.","status":"active","version":"1.4.2","language":"javascript","source_language":"en","source_url":"https://github.com/bspaulding/rollup-plugin-image-files","tags":["javascript","rollup-plugin","image"],"install":[{"cmd":"npm install rollup-plugin-image-files","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-image-files","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-image-files","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for plugin interface","package":"rollup","optional":false}],"imports":[{"note":"ESM default import is standard; CJS require may not work if package does not export CJS.","wrong":"const images = require('rollup-plugin-image-files')","symbol":"default","correct":"import images from 'rollup-plugin-image-files'"},{"note":"The default export is the plugin factory function.","wrong":"","symbol":"images","correct":"import images from 'rollup-plugin-image-files'"}],"quickstart":{"code":"import 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};","lang":"javascript","description":"Basic Rollup configuration using rollup-plugin-image-files to handle image imports by copying files to output."},"warnings":[{"fix":"Ensure unique image filenames or use a custom naming function (if supported).","message":"Plugin copies images to the same directory as the output bundle; may cause path collisions if multiple images have the same filename.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use static import paths for images.","message":"Only works with static image imports (string literal paths); dynamic imports or computed paths are not handled.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set output.format to 'cjs' in Rollup config.","message":"Output format must be CommonJS (cjs) for the generated require() calls to work in Node.js environments like React Native.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure plugin is added to plugins array and images are in a directory relative to the source file.","cause":"Plugin not installed or configured correctly; Rollup cannot resolve image file.","error":"Error: Could not resolve '../path/to/image.png' from 'src/index.js'"},{"fix":"Use `plugins: [images()]` not `plugins: [images]`.","cause":"Attempting to call the import as a function, but the import is the default export which is already a function (should be called in plugins array).","error":"TypeError: images is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}