Socket
Socket
Sign inDemoInstall

@rollup/plugin-url

Package Overview
Dependencies
Maintainers
4
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rollup/plugin-url

Import files as data-URIs or ES Modules


Version published
Weekly downloads
151K
increased by10.45%
Maintainers
4
Weekly downloads
 
Created

What is @rollup/plugin-url?

@rollup/plugin-url is a Rollup plugin that allows you to import files as data-URIs or ES modules. This is particularly useful for handling assets like images, fonts, and other media files in your JavaScript projects.

What are @rollup/plugin-url's main functionalities?

Importing files as data-URIs

This feature allows you to import files (e.g., images) as data-URIs, which can be embedded directly into your JavaScript code. This is useful for small files that you want to include directly in your bundle.

import imageUrl from './image.png';

Importing files as ES modules

This feature allows you to import files as ES modules, which can be useful for larger files that you want to keep separate from your main JavaScript bundle. The plugin can be configured to decide when to use data-URIs and when to use ES modules based on file size.

import imageUrl from './image.png';

Customizing file handling

This feature allows you to customize how files are handled by specifying options like file size limits, file types to include, and whether to emit files to the output directory. This gives you fine-grained control over how assets are managed in your project.

import url from '@rollup/plugin-url';

export default {
  input: 'src/index.js',
  output: {
    dir: 'output',
    format: 'es'
  },
  plugins: [
    url({
      limit: 10 * 1024, // 10 KB
      include: ['**/*.svg', '**/*.png', '**/*.jpg', '**/*.gif'],
      emitFiles: true // Emit files to output directory
    })
  ]
};

Other packages similar to @rollup/plugin-url

Keywords

FAQs

Package last updated on 05 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc