🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

esbuild-plugin-blurhash-as

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-plugin-blurhash-as

ESBuild plugin for blurhash-as

latest
Source
npmnpm
Version
0.10.1
Version published
Maintainers
1
Created
Source

esbuild-plugin-blurhash-as

ESBuild plugin for generating Blurhash with blurhash-as

NPM JavaScript Style Guide

Install

npm install --save-dev esbuild-plugin-blurhash-as
yarn add -D esbuild-plugin-blurhash-as

Usage

Config

NOTE: If you are using an image loader plugin that allows imports for .jpg or .png, make sure that the blurhash plugin is called first.

NOTE: If you aren't using an image loader plugin, make sure that the loader option for esbuild is set:

loader: {
  '.jpg': 'file',
  '.png': 'file,
},
import blurhash from 'esbuild-plugin-blurhash-as';

esbuild.build({
  plugins: [
    blurhash(),
  ],
  loader: {
    '.jpg': 'file',
    '.png': 'file,
  },
});

Code

// Allows importing both JPG and PNG files
// Valid blurhash values includes "css", "svg", "jpg" and "png"
import * as image from './example.jpg?blurhash=css';

console.log(image);
// {
//   // The blurhash of the image
//   hash: '...',
//   // The generated placeholder
//   // For "svg", "jpg" and "png",
//   // This is a string output.
//   placeholder: {...},
//   // The url of the image
//   source: '...',
//   // Dimensions of the image
//   width: ...,
//   height: ...,
// }

With react-blurhash-as

Basic Rendering

import { Blurhash } from 'react-blurhash-as';
import * as image from './example.jpg?blurhash=css';

<Blurhash
  mode="css" // "svg", "canvas" or "image
  src={image.source}
  alt=""
  width={image.width}
  height={image.height}
  hash={image.hash}
/>

Static Rendering

import { BlurhashStatic } from 'react-blurhash-as';
import * as image from './example.jpg?blurhash=css';

<BlurhashStatic
  mode="css" // "svg" or "image"
  src={image.source}
  alt=""
  width={image.width}
  height={image.height}
  placeholder={image.placeholder}
/>

Typescript

You can refer to esbuild-plugin-blurhash-as/shim:

/// <reference types="esbuild-plugin-blurhash-as/shim" />

Sponsors

Sponsors

License

MIT © lxsmnsyc

Keywords

pridepack

FAQs

Package last updated on 15 Mar 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