rollup-plugin-import-data-uri
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

rollup-plugin-import-data-uri

A simple plugin to import any file as a data URI.

Compatible with Rollup and Vite.

This plugin is not the same as @rollup/plugin-data-uri - this plugin creates data URIs and exports them, whilst @rollup/plugin-data-uri allows you to import raw code from data URIs.

Usage

Configuration

Vite

// vite.config.js
import dataURIPlugin from 'rollup-plugin-import-data-uri';

export default {
    plugins: [dataURIPlugin(), /* other plugins */],
    /* also the rest of your configuration */
}

Example

If you're using Vite, the following would give you a URL to the image.

import IMAGE from './image.png';

Appending ?data-uri to the end of the import would make it a string containing a data URI:

import IMAGE from './image.png?data-uri';

This is suitable for embedding images.

Licence

This project is licensed under the MIT licence. See the full licence text here.

Package Sidebar

Install

npm i rollup-plugin-import-data-uri

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

5.94 kB

Total Files

11

Last publish

Collaborators

  • tecc