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 🙏

© 2025 – Pkg Stats / Ryan Hefner

holistic-image

v1.4.0

Published

Automatic image optimization and serving

Downloads

14

Readme

holistic-image

Holism is the idea that various systems should be viewed as wholes, not merely as a collection of parts.

Build-time Automatic image transformation and Holistic management

  • 🍊 uses squoosh to derive jpg, webp, avif from your sources
  • 📦 hides implementation details behind Webpack
  • 🤖 on demand file creation, and CLI utils to verify integrity
  • ⚛️ optional React implementation

Structure

This is a convention over configuration library, and all you need is to follow our convention

Having ➡️

├── [email protected]

️Will produce ⬇️

├── [email protected]
├── .holistic (you can hide this directory)
│   └─ image@2x
│      ├─ [email protected]
│      ├─ [email protected]
│      ├─ [email protected]
│      ├─ [email protected]
│      ├─ [email protected]
│      ├─ [email protected]
|      ├─ derived.scss
│      └─ [email protected]

The same principle will be applied during the import - instead of importing [email protected] you will get a pointer to all files below

Note: holistic-image does not produce png output (configurable) as the end user is expected to use webp or avif

Usage

Step 1 - derive files

holistic-image is looking for files named accordingly - image.holistic.png(or jpg) and derives the "missing" ones - optimized jpg, webp and avif

If the source file named as [email protected](Figma standard), then @1x version will be generated automatically

How to use

  • via Webpack loader Just use webpack loader with autogenerate option enabled (default)
  • via API
// generate-images.js
import {deriveHolisticImages} from "holistic-image/api";

deriveHolisticImages(
  /root folder*/
process.argv[2],
  /*mask*/ process.argv[3],
// /*optional*/ squoosh ecoders with options
)

And then in package.json

// package.json
 "autogen:images": "yarn generate-images.js $INIT_CWD 'src/**/*'",
  • via CLI
// package.json
"autogen:images":"holistic-image derive  $INIT_CWD 'src/**/*'"
"validate:images":"holistic-image validate  $INIT_CWD 'src/**/*'"

Step 2 - configure webpack to process images

  • Optimized config, will remove originals from the final bundle
import { holisticImage } from 'holistic-image/webpack';

webpack.config = {
  module: {
    rules: {
      oneOf: [holisticImage, yourFileLoader],
      // .. rest of your config
    },
  },
};
  • automatic image generation will be enabled if process.env.NODE_ENV is set to development

  • to fine control settings use:

    • import { holisticImagePresetFactory } from 'holistic-image/webpack';
    • import { holisticImageLoader } from 'holistic-image/webpack';
  • Easy config (for storybook for example), everything will work as well

import { holisticImage } from 'holistic-image/webpack';

webpack.config = {
  module: {
    rules: {
      holisticImage,
      yourFileLoader,
      // .. and rest of your config
    },
  },
};

Step 3 - use

import image from './image.holistic.jpg';
// ^ not an image, but HolisticalImageDefinition
image = {
  base: [1x, 2x],
  webp: [1x, 2x],
  avif: [1x, 2x],
  [META]: {width, height, ratio}
}

Build in React component

import { Image } from 'holistical-image/react';
import image from './image.holistic.jpg';
import imageXS from './imageXS.holistic.jpg';

<Image src={image} media={{ 'max-width: 600px': imageXS }} />;
// 👇 6-12 images generated, the right picked, completely transparent

TypeScript integration

While this library provides d.ts for the file extension it can be more beneficial to provide your own ones, as you did for .jpg and other static asses already

declare module '*.holistic.jpg' {
  import type { HolisticalImageDefinition } from 'holistic-image';

  const content: HolisticalImageDefinition;
  export default content;
}

Configuration

Configuration is possible in two modes:

.holistic-imagerc.yaml (can be json or js as well)

# derived from https://github.com/GoogleChromeLabs/squoosh/blob/61de471e52147ecdc8ff674f3fcd3bbf69bb214a/libsquoosh/src/codecs.ts
---
jpg:
  use: mozjpeg
  # with default 75
  options:
    - quality: 80 # for scale 1x
    - quality: 70 # for scale 2x
webp:
  use: webp
  # with default 75
  options:
    - quality: 85
      method: 6
avif:
  use: avif
  # with default 33
  options:
    - cqLevel: 20
      effort: 5
    - cqLevel: 28
      effort: 5

Hiding .holistic output files

folders starting from . already expected to be hidden for IDE, but keep in mind - derived files are expected to be commited.

WebStorm/IDEA

You can use idea-exclude to automaticaly configure Idea-based solutions to exclude these folders

  • run idea-exclude holistic-images "src/**/.holistic"

VCS

"files.exclude": {
    "**/.holistic": true
}

See also

License

MIT