Skip to content

Latest commit

 

History

History
74 lines (47 loc) · 2.15 KB

README.md

File metadata and controls

74 lines (47 loc) · 2.15 KB

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)