Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svg-url-loader

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svg-url-loader

Converts SVG file to utf-8 encoded data-uri string

  • 8.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is svg-url-loader?

The svg-url-loader npm package is a webpack loader that inlines SVGs as URLs. This can be useful for embedding SVGs directly into your CSS or JavaScript files, reducing the number of HTTP requests and potentially improving load times.

What are svg-url-loader's main functionalities?

Inlining SVGs as URLs

This feature allows you to inline SVGs as URLs in your JavaScript or CSS files. The code sample shows a basic webpack configuration that uses svg-url-loader to process SVG files.

module.exports = {
  module: {
    rules: [
      {
        test: /\.svg$/,
        use: 'svg-url-loader'
      }
    ]
  }
};

Customizing URL encoding

This feature allows you to customize the URL encoding of the inlined SVGs. The code sample shows how to configure svg-url-loader to use base64 encoding for the SVG URLs.

module.exports = {
  module: {
    rules: [
      {
        test: /\.svg$/,
        use: {
          loader: 'svg-url-loader',
          options: {
            encoding: 'base64'
          }
        }
      }
    ]
  }
};

Limiting file size

This feature allows you to limit the size of the SVG files that are inlined. Files larger than the specified limit will be handled by the default file loader. The code sample shows how to set a limit of 10KB for inlining SVGs.

module.exports = {
  module: {
    rules: [
      {
        test: /\.svg$/,
        use: {
          loader: 'svg-url-loader',
          options: {
            limit: 10000
          }
        }
      }
    ]
  }
};

Other packages similar to svg-url-loader

Keywords

FAQs

Package last updated on 04 Sep 2022

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