brk_rolldown_plugin_data_uri

Crates.iobrk_rolldown_plugin_data_uri
lib.rsbrk_rolldown_plugin_data_uri
version0.1.5
created_at2025-06-14 23:12:42.158814+00
updated_at2025-09-08 16:58:26.025128+00
descriptionbrk fork of rolldown_plugin_data_uri
homepage
repository
max_upload_size
id1712742
size76,327
(nym21)

documentation

README

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
Commit count: 0

cargo fmt