Registry / web-framework / rollup-plugin-image-file

rollup-plugin-image-file

JSON →
library1.0.2jsnpmunverified

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.

npm install rollup-plugin-image-file
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-IMAG
R
rollup-plugin-image-file
web-frameworkjavascriptv1.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (images)
import images from 'rollup-plugin-image-files'
import { images } from 'rollup-plugin-image-files'
The plugin exports a default function; named import will be undefined.
require (CJS)
const images = require('rollup-plugin-image-files')
const { images } = require('rollup-plugin-image-files')
CommonJS require returns the default export as a whole.
TypeScript types
import images from 'rollup-plugin-image-files'
Types are shipped; no separate type import needed.

Shows basic setup: import the plugin, add to Rollup config, and use an image import in source.

// rollup.config.js import images from 'rollup-plugin-image-files'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'cjs' }, plugins: [images()] }; // src/index.js import logo from './logo.png'; console.log(logo); // e.g., './dist/logo.png'
Debug
Known issues
gotchaImage files must be in the same directory as the output bundle or relative paths break.
fix
Ensure images are placed in a directory relative to the output, or use a custom copy function.
affects: >=1.0.0
gotchaThe plugin may not handle SVG or non-raster images well; only tested with PNG/JPEG.
fix
Use a dedicated plugin for SVG or other formats.
affects: >=1.0.0
deprecatedThe original package name 'rollup-plugin-image-files' is a fork; the underlying plugin 'rollup-plugin-image' is more maintained.
fix
Consider using rollup-plugin-image if base64 inlining is acceptable.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Could not resolve '../path/to/image.png' from 'src/index.js'
Image path is relative to source file, but Rollup cannot resolve non-JS files without plugin.
fix
Add the plugin to rollup config and ensure the image exists at the specified path.
TypeError: images is not a function
Named import used instead of default import.
fix
Use default import: import images from 'rollup-plugin-image-files'
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
rolluprequiredPeer dependency: the plugin hooks into Rollup's build system.
Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-image-file — npm install rollup-plugin-image-file · libregistry