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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vite-plugin-vsharp

v1.9.1

Published

A Vite plugin that compresses static images after each builds by using sharp.js

Readme

VSharp: Simple Image Compression for Vite Projects

VSharp is a Vite plugin that makes image optimization easy. It uses the powerful Sharp library to automatically compress your images during the build process. This means faster-loading websites with high-quality images, all without any extra work on your part.

Features

  • Works with common image formats: .jpg/.jpeg, .png, .gif, and .webp
  • Uses Sharp's proven compression methods for each format type (Sharp documentation)

Getting Started

Installation

Add VSharp to your project:

npm install vite-plugin-vsharp --save-dev

Basic Setup

Add VSharp to your Vite config file:

// vite.config.js
import vsharp from 'vite-plugin-vsharp';

export default {
  plugins: [
    vsharp({
      // Your options here
    }),
  ],
};

Configuration Options

Here's how you can customize VSharp to fit your needs:

  1. exclude: Skip specific images during compression. Just list the filenames:

    // vite.config.js
    {
      plugins: [
        vsharp({
          exclude: [
            "bg.jpg", // Won't compress this file
            // Note: Just use filenames, no paths needed
          ],
        }),
      ]
    }
  2. excludePublic: Skip images in your public folder using patterns:

    // vite.config.js
    {
      plugins: [
        vsharp({
          excludePublic: [
            "public/*", // Skip everything in public
            "public/test_img/*", // Skip all images in test_img
          ],
        }),
      ]
    }
  3. includePublic: Choose specific files to compress from excluded folders:

    // vite.config.js
    {
      plugins: [
        vsharp({
          excludePublic: [
            "public/*" // Skip all public files
          ],
          includePublic: [
            "public/images/*", // But compress files in this folder
            "public/test_img/001.jpg", // And this specific image
          ],
        }),
      ]
    }

    Note: includePublic takes priority over excludePublic, letting you:

    • First exclude entire folders
    • Then pick specific files or folders to include
    • Use either patterns or exact file paths
  4. Image Size Options: Control how your images are resized:

    // vite.config.js
    {
      plugins: [
        vsharp({
          width: 800, // Maximum width (won't upscale smaller images)
          height: 800, // Maximum height (won't upscale smaller images)
          scale: 0.8, // Or use this to reduce by percentage (overrides width/height)
        }),
      ]
    }
  5. Metadata Options: Keep important image information:

    // vite.config.js
    {
      plugins: [
        vsharp({
          preserveMetadata: {
            orientation: true, // Keeps correct image orientation
          },
        }),
      ]
    }

Default Settings

VSharp comes with these sensible defaults, which you can override as needed:

{
  "includePublic": [],
  "excludePublic": [],
  "exclude": [],
  ".jpg": {
    "quality": 80
  },
  ".jpeg": {
    "quality": 80
  },
  ".png": {
    "quality": 80,
    "palette": true
  },
  ".webp": {
    "lossless": true
  },
  ".gif": {
    
  },
  "preserveMetadata": {
    "orientation": false
  }
}

For more advanced options, check out the Sharp documentation.