Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@adonesp/rollup-plugin-image-base64

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adonesp/rollup-plugin-image-base64

Import JPG, PNG and GIF images as base64 strings

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

rollup-plugin-image-base64

Import JPG, PNG, GIF and SVG files.

Fork of rollup-plugin-image to skip the part in which a new Image() is created and just return the base64 as String

Installation

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

Usage

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

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

You can now use images in your bundle like so:

import logo from './rollup.png';

console.log(logo); // base64 of image as String

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

Original code by Rich Harris

Keywords

FAQs

Package last updated on 11 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc