New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

esbuild-plugin-inline-image

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-plugin-inline-image

`esbuild` plugin for inlining yout images conditionaly on size

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.3K
decreased by-9.19%
Maintainers
1
Weekly downloads
 
Created
Source

esbuild-plugin-inline-image

esbuild plugin for inlining yout images conditionaly on size

Aka. switches loader for image between file and dataurl depending on size (as in Webpack)

Instalation

yarn add esbuild-plugin-inline-image

or

npm install esbuild-plugin-inline-image

Usage

Add it to your esbuild plugins list:

const esbuild = require("esbuild");
const inlineImage = require("esbuild-plugin-inline-image");

esbuild.build({
  ...
  plugins: [
    ...
    inlineImage()
  ]
  ...
});

You can then import images

import logo from "../assets/logo.png";

Options

By default it works for .jpg, .png, .gif, .svg, .webp, .avif extensions.

You can customize the options (ie. to disable svg loading if being handled by different plugin)

inlineImage({
  // options
});

Allowed options are:

  • limit: define image limit (in bytes) for size after which the image wll not be inline (default is 10000)

    • limit can also be set from env as IMAGE_INLINE_SIZE_LIMIT
  • extensions: an array of extensions to work on (default is [ "jpg", "png", "gif", "svg", "webp", "avif" ])

  • filter: you can also pass filter for onLoad directly, but in this case you need to manually set esbuild loader option for the extensions to file

License

Licensed as MIT open source.

Keywords

FAQs

Package last updated on 27 Nov 2021

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