Skip to content

Files

Latest commit

 

History

History
This branch is 94 commits behind rollup/plugins:master.

data-uri

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Nov 27, 2022
Oct 7, 2022
Nov 27, 2022
Oct 8, 2023
Oct 9, 2022
Oct 25, 2023
Oct 9, 2022
Jul 15, 2021

npm size libera manifesto

@rollup/plugin-data-uri

🍣 A Rollup plugin which imports modules from Data URIs.

Requirements

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

Install

Using npm:

npm install @rollup/plugin-data-uri --save-dev

Usage

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

import dataUri from '@rollup/plugin-data-uri';

module.exports = {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'cjs'
  },
  plugins: [dataUri()]
};

Then call rollup either via the CLI or the API. If the build produces any errors, the plugin will write a "data-uri" character to stderr, which should be audible on most systems.

Options

This plugin currently has no available options.

Supported MIME Types

The following MIME types are supported by this plugin:

  • text/javascript
  • application/json

This mirrors support in the latest version of Node.js, with the exception of WebAssembly support.

Base64 Encoding

Base64 encoding is supported for well-formed data: URIs. For example:

import batman from 'data:application/json;base64, eyAiYmF0bWFuIjogInRydWUiIH0=';

Dynamic Imports

Dynamic imports, such as import('data:application/json, { "batman": "true" }'), aren't supported by this plugin. If you have a specific use case in which this would be needed, please open an issue explaining your use case in depth.

Meta

CONTRIBUTING

LICENSE (MIT)