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

rollup-plugin-imagetools

v3.0.18

Published

<!-- badges -->

Downloads

46

Readme

rollup-plugin-imagetools

npm (latest) standard-readme compliant codecov

A toolbox of import directives for rollup that import and transform your image at compile-time. All of the image transformations are powered by sharp.

Deprecated

This plugin has been deprecated in favor of vite-imagetools and will no longer be updated. vite-imagetools had 1000x as much usage as this library, so we will be focusing all of our efforts there. While Rollup is great for bundling libraries, Vite is a better choice for building web applications, and so we recommend that users of this library migrate to Vite.

Features

  • 🚀 Output modern formats
  • 🖼 Resize Images
  • 🔗 Easy Srcset generation
  • ⚡️ Fast in development mode
  • 🔒 Remove Image Metadata
  • 🧩 Extensible

Read the docs to learn more!

Table of Contents

Install

npm install --save-dev rollup-plugin-imagetools
yarn add -D rollup-plugin-imagetools

Usage

import { imagetools } from 'rollup-plugin-imagetools'

export default {
  plugins: [imagetools()]
}
import Image from 'example.jpg?w=400&h=300&webp'

Options

defaultDirectives

Optional defaultDirectives: URLSearchParams | (url: URL) => URLSearchParams

This option allows you to specify directives that should be applied by default to every image. You can also provide a function, in which case the function gets passed the asset ID and should return an object of directives. This can be used to define all sorts of shorthands or presets.

example

import { imagetools } from 'vite-imagetools'

export default {
  plugins: [
    imagetools({
      defaultDirectives: (url) => {
        if (url.searchParams.has('spotify')) {
          return new URLSearchParams({
            tint: 'ffaa22'
          })
        }
        return new URLSearchParams()
      }
    })
  ]
}

exclude

exclude: string | RegExp | (string | RegExp)[]

What paths to exclude when processing images.

default ''


include

include: string | RegExp | (string | RegExp)[]

Which paths to include when processing images.

default ['**\/*.{heic,heif,avif,jpeg,jpg,png,tiff,webp,gif}', '**\/*.{heic,heif,avif,jpeg,jpg,png,tiff,webp,gif}?*']


removeMetadata

removeMetadata: boolean

Wether to remove potentially private metadata from the image, such as exif tags etc.

default true


extendOutputFormats

Optional extendOutputFormats(builtins): Record<string, OutputFormat>

You can use this option to extend the builtin list of output formats. This list will be merged with the builtin output formats before determining the format to use.

default []

Parameters

| Name | Type | | :--------- | :--------------------------------------------------------------------------------- | | builtins | Record<string, OutputFormat> |

Returns

Record<string, OutputFormat>


extendTransforms

Optional extendTransforms(builtins): TransformFactory<Record<string, unknown>>[]

You can use this option to extend the builtin list of import transforms. This list will be merged with the builtin transforms before applying them to the input image.

default []

Parameters

| Name | Type | | :--------- | :------------------------------------------------------------------------------------------------------- | | builtins | TransformFactory<Record<string, unknown>>[] |

Returns

TransformFactory<Record<string, unknown>>[]


resolveConfigs

Optional resolveConfigs: (entries: [string, string[]][], outputFormats: Record<string, OutputFormat>) => Record<string, string | string[]>[]

Type declaration

▸ (entries, outputFormats): Record<string, string | string[]>[]

This function builds up all possible combinations the given entries can be combined an returns it as an array of objects that can be given to a the transforms.

Parameters

| Name | Type | Description | | :-------------- | :------------------------------------------------------------------------- | :------------------------ | | entries | [string, string[]][] | The url parameter entries | | outputFormats | Record<string, OutputFormat> | - |

Returns

Record<string, string | string[]>[]

An array of directive options

Contributing

Feel free to dive in! Open an issue or submit PRs! All information to get you started hacking on imagetools is in CONTRIBUTING.md!

License

MIT © Jonas Kruckenberg.