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

1.0.3 • Public • Published

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)

Dependents (0)

Package Sidebar

Install

npm i @rollup/plugin-data-uri

Weekly Downloads

74

Version

1.0.3

License

MIT

Unpacked Size

9.04 kB

Total Files

6

Last publish

Collaborators

  • shellscape
  • rich_harris
  • guybedford
  • lukastaegert