rollup-plugin-image-files2

1.4.6 • Public • Published

rollup-plugin-image-files

Build Status

Like rollup-plugin-image, but writes image files to dest instead of inlining base64. This was written for a library that would be consumed by react-native applications.

Usage

Install the plugin via npm:

npm install --save-dev rollup-plugin-image-files

Add the plugin to your rollup config:

import images from 'rollup-plugin-image-files';

export default {
	entry: 'src/index.js',
	des: 'dist/bundle.js',
	plugins: [
		images({
			output: 'build/images'
		})
	]
};

Require some images in your source:

import React from 'react';
import { Image } from 'react-native';
import imageSrc from '../path/to/image.png';

export default const MyComponent = () => (
  <img src={imageSrc} alt='' />
);

What it does

The plugin does two things:

  1. Copies the source image into the same directory as the destination file.
  2. Replaces the image required with a module that exports the result of calling require on the copied image.

Readme

Keywords

Package Sidebar

Install

npm i rollup-plugin-image-files2

Weekly Downloads

0

Version

1.4.6

License

MIT

Unpacked Size

11.3 kB

Total Files

11

Last publish

Collaborators

  • dongyuwei