3.0.3 • Published 2 years ago

@rollup/plugin-image v3.0.3

Weekly downloads
98,542
License
MIT
Repository
github
Last release
2 years ago

npm size libera manifesto

@rollup/plugin-image

šŸ£ A Rollup plugin which imports JPG, PNG, GIF, SVG, and WebP files.

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.

Requirements

This plugin requires an LTS Node version (v14.0.0+) and Rollup v1.20.0+.

Install

Using npm:

npm install @rollup/plugin-image --save-dev

Usage

Assuming a src/index.js exists and contains code like the following:

import logo from './rollup.png';

console.log(logo);

Create a rollup.config.js configuration file and import the plugin:

import image from '@rollup/plugin-image';

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [image()]
};

Then call rollup either via the CLI or the API.

Once the bundle is executed, the console.log will display the Base64 encoded representation of the image.

Options

dom

Type: Boolean Default: false

If true, instructs the plugin to generate an ES Module which exports a DOM Image which can be used with a browser's DOM. Otherwise, the plugin generates an ES Module which exports a default const containing the Base64 representation of the image.

Using this option set to true, the export can be used as such:

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

exclude

Type: String | Array[...String] Default: null

A picomatch pattern, or array of patterns, which specifies the files in the build the plugin should ignore. By default no files are ignored.

include

Type: String | Array[...String] Default: null

A picomatch pattern, or array of patterns, which specifies the files in the build the plugin should operate on. By default all files are targeted.

Meta

CONTRIBUTING

LICENSE (MIT)

wdsite-utilsmindee-sdk-reactfuze-tealegal-content-front-webmylib2-test-img@victoriatong/common-componentreact-mxgraph-editorfcasb-uitooltipme-test2mk-beter-clinamefilter-lzmsmartbarcode-web-corealchera-storybookalchera-testmaccha.manager@ithinkdt-cloud/vite-ithinkdt-vue@pasha28198/molequle-web-commonjcinvcc@rakuten-rampage/rampagepoc-wc-tssharedcomponents-dartdigitaldecal-components-prova2anatoliy-bundlerreact-ui-materialsaxie-animationvvi-uidyc1-components@infinitebrahmanuniverse/nolb-_rol@thequack/sharedapp-rollup-cli@fqran/infinite-passsssiiixxx@everything-registry/sub-chunk-788abhishek_pkgawantunai-design-system-v1@rygaa/react-ui-component2_sembra-library-testeolluga-uitalentorg-profile-editortabel-to-csvt-ui-compoanytemplates-local-2test-hw-test-onetest-mylib3test-package-urtest-plugin-foodpagetest-pico-commvvsogi-testvue-image-mixvue-big-screenwebb-lite-componentworkspacedwrapper-aggrid-genrexcratch-buildwtt-pkgwhatsapp-chat-boxwi9-sp-uixkcws-react-sdktechnotictest-test-test-onetesting-reopo-paystest-rollup-sbtest_lib_react_cp_as_lib_dimatest_quadratectest-template2test-template233swift-testvue-drawing-boardvue-chart-npmvite-plugin-testing@dinnovate/cloudmap_npm@dev-felini/ui-base-lib@dev-felini/ui-layout-lib@boty-design/fe-cli@boty-design/fe-plugin-eslint@rpg-engine/long-bow@payloadcms/bundler-vite@ruby-labs/ruby-web-common@ruby-labs/ruby-ui-corebinge-sdk-provideriv-npmjs-bxt-uijs-sfpt-uiisomtrik-quickchatisometrik-webchatk-field-modulek-fe-plugin-build-umdk-field-module-textkennethmoveo-uicomponentskwedialogkwetextinputl-ui-compoanykt-maplibre-gl-drawktaro-community-cliktaro-clithai-library-react-component-core@alma/fragments@logra/component-library@digitalfactory/components
3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.6

4 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago