1. rollup-plugin-inline-image
inline JPG, PNG, GIF and SVG images into rollup bundle
rollup-plugin-inline-image
Package: rollup-plugin-inline-image
Created by: wayou
Last modified: Mon, 16 May 2022 04:26:53 GMT
Version: 0.1.0
License: MIT
Downloads: 389
Repository: https://github.com/wayou/rollup-plugin-inline-image

Install

npm install rollup-plugin-inline-image
yarn add rollup-plugin-inline-image

rollup-plugin-inline-image

inline JPG, PNG, GIF and SVG images into rollup bundle.

This same as rollup/rollup-plugin-image but the ouput of rollup-plugin-image is module code witch won't work in umd format. This fork ouput plain string code which can be transformed by Typescript or babel and available in umd format.

Installation

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

Usage

 // rollup.config.js
import image from 'rollup-plugin-inline-image';

export default {
  entry: 'src/index.js',
  dest: 'dist/my-lib.js',
  plugins: [
    image()
  ]
};

You can now use images in your bundle like so:

 import logo from './rollup.png';
document.body.appendChild( logo );

Images are encoded using base64, which means they will be 33% larger than the size on disk. You should therefore only use this for small images where the convenience of having them available on startup (e.g. rendering immediately to a canvas without co-ordinating asynchronous loading of several images) outweighs the cost.

License

MIT

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code