npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vite-plugin-blurhash-sharp-fix-fork

v0.2.1

Published

Vite plugin to create blurhash strings for all images inside a certain directory, or from the provided set of images. Hashes are then saved to an output file and stored in vite's define global variables.

Downloads

5

Readme

vite-plugin-blurhash

Install

npm i vite-plugin-blurhash -D # yarn add vite-plugin-md -D

Add it to vite.config.js

import Blurhash from 'vite-plugin-blurhash'

export default{
	plugins:[
		...plugins,
		Blurhash() //Hashing images from /src/assets/images
	]
}

Use

Blurhash strings are saved as a camelcase version of the file name and path from the root. For example if you use the default image directory /src/assets/images, and your file structure looks like this:

- images
--- rick-and-morty.png
--- blog-images
-------- solar-opposites.png

You would get blurhash strings at the following variables:

rickAndMortyPng
blogImagesSolarOppositesPng

Use the hash strings anywhere inside the app. Maybe with something like vue-blurhash.

<template>
  <blur-hash-image
    width="400"
    height="300"
    :hash="rickAndMortyPng"
    src="https://images.unsplash.com/photo-1545910684-8e7c081be9b0?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1867&q=80"
    alt="green lawn grass during daytime"
  />
</template>

Your blurhash strings are also stored inside /src/assets/images/blurhash-map.json, so you can feel free to import from there as well.

Options

Blurhash({
	imageDir?:  string  |  boolean, //Where to look for images to hash, or false. Default /src/assets/images
	mapPath?:  string, //Where should the hash map be stored, or false. Default /src/assets/images/blurhash-map.json
	define?:  boolean, //Should we define the hashes as vite variables. Default true
	images?:  Images, //Additional images to hash. { [key: string]: string }
	log?:  boolean, //Should we log progress as we hash
})

Images

You can define images to hash, and their variables names in this option. Images here can be local paths are urls.

Blurhash({
	images: {
		waterMelon:  'https://solidstarts.com/wp-content/uploads/when-can-babies-eat-watermelon.jpg',
		flamingo:  '/src/assets/flamingo.jpg'
	}
})

Now you'll have access to waterMelon and flamingo inside the app.

Other options

  • Define: Should we store the resulting hashes inside of vite variables. Defaults to true.
  • Log: Should we log progress as we hash. Defaults to true.
  • imageDir: Where to look for images to hash, or false to not look for images inside of a directory. This means that we will only look for images inside of the images parameter. Defaults to /src/assets/images.
  • mapPath: Where should the hash map be stored, or false to not store it. Defaults to /src/assets/images/blurhash-map.json.

Thanks

  • 🌫 woltapp/blurhash - the original blurhash library.
  • ⚡️ vite - it's rad.
  • 🙏 @antfu - learned a lot from his work.
  • All the other great libs used in this project.