#data-url #plugin #uri #rolldown

rolldown_plugin_data_uri

Rolldown plugin for data URI handling

1 unstable release

0.1.0 Oct 17, 2025

#2125 in Web programming

50 downloads per month
Used in 2 crates (via rolldown)

MIT license

23KB
73 lines

Maintenance Guide

A plugin for rolldown-vite that enables loading data: URIs as modules, ported from Vite's dataUriPlugin.

This plugin is exclusive to rolldown-vite and is not recommended for external use.

📦 What it does

This plugin enables native support for data: URLs in JavaScript, CSS, and JSON contexts by resolving and loading them as virtual modules.

Supported MIME types:

  • text/css → loaded as CSS module

  • text/javascript → loaded as JS module

  • application/json → loaded as JSON module

Other MIME types are ignored and fall back to default behavior.

🚀 Debug Usage

This plugin is enabled by default in rolldown, so no manual configuration is required.

import msg from 'data:text/javascript,export default "hello from data URI"';
console.log(msg); // -> hello from data URI

If you want to specify the type of module, you can define 'module_ext': module_type. For example, if you want to import files with ext .png as dataurl module.

import { defineConfig } from 'rolldown';

export default defineConfig({
  input: './index.js',
  moduleTypes: {
    '.png': 'dataurl',
  },
});

It will yield

// #region example.png
var example_default$12 = 'data:image/png,png';

// #endregion

Dependencies

~41–70MB
~1M SLoC