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

@oncede/snowpack-plugin-once-image-sharp

v1.0.0

Published

snowpack plugin to use sharp with percentages

Downloads

7

Readme

@oncede/snowpack-plugin-once-image-sharp

NPM Version Downloads Stats

This snowpack plugin allows you to use the sharp image library with percentages for width.

Installation

npm i -D @oncede/snowpack-plugin-once-image-sharp@latest sharp@latest

Run example

git clone @oncede/snowpack-plugin-once-image-sharp . && npm i && npm run example build

Usage

options.forceRebuild only takes effect if buildOption.clean is set to false buildOption.clean clears the whole dist folder By default previously generated images would be skipped. (checked with fs.access by path ) 


"plugins": [
        [
            "@oncede/snowpack-plugin-once-image-sharp",
            {
                "options": {
                    "silent": true,
                    "forceRebuild": false,
                    "defaultFormat": "webp",
                    "jsonOutput": "image_sizes.json",
                    "generateImagesOnDev": false
                },
                "imageConfig": {
                    "**/*.jpg": [
                        {
                            "resize": {
                                "width": "1%"
                            },
                            "rename": { "suffix": "-init" },
                            "format": "webp",
                            "formatOptions": {
                                "quality": 80
                            },
                            "blur": true
                        },
                        {
                            "resize": {
                                "width": "5%"
                            },
                            "rename": { "suffix": "-5" },
                            "format": "webp",
                            "formatOptions": {
                                "quality": 80
                            }
                        },
                        {
                            "resize": {
                                "width": "20%"
                            },
                            "rename": { "suffix": "-20" },
                            "format": "webp",
                            "formatOptions": {
                                "quality": 80
                            }
                        },
                        {
                            "resize": {
                                "width": "40%"
                            },
                            "rename": { "suffix": "-40" },
                            "format": "webp",
                            "formatOptions": {
                                "quality": 80
                            }
                        },
                        {
                            "resize": {
                                "width": "60%"
                            },
                            "rename": { "suffix": "-60" },
                            "format": "webp",
                            "formatOptions": {
                                "quality": 80
                            }
                        },
                        {
                            "resize": {
                                "width": "80%"
                            },
                            "rename": { "suffix": "-80" },
                            "format": "webp",
                            "formatOptions": {
                                "quality": 80
                            }
                        },
                    ]
                }
            }
        ]
    ]
{
    "/assets/img/": {
        "dariusz-sankowski-dvK_CT1Wg78-unsplash": {
            "dariusz-sankowski-dvK_CT1Wg78-unsplash-init.webp": {
                "format": "webp",
                "size": -1,
                "width": 46,
                "height": 35
            },
            "dariusz-sankowski-dvK_CT1Wg78-unsplash-5.webp": {
                "format": "webp",
                "size": -1,
                "width": 230,
                "height": 173
            },
            "dariusz-sankowski-dvK_CT1Wg78-unsplash-10.webp": {
                "format": "webp",
                "size": -1,
                "width": 461,
                "height": 346
            },
            "dariusz-sankowski-dvK_CT1Wg78-unsplash-20.webp": {
                "format": "webp",
                "size": -1,
                "width": 922,
                "height": 692
            },
            "dariusz-sankowski-dvK_CT1Wg78-unsplash-30.webp": {
                "format": "webp",
                "size": -1,
                "width": 1382,
                "height": 1037
            },
            "dariusz-sankowski-dvK_CT1Wg78-unsplash-40.webp": {
                "format": "webp",
                "size": -1,
                "width": 1843,
                "height": 1382
            },
            "dariusz-sankowski-dvK_CT1Wg78-unsplash-50.webp": {
                "format": "webp",
                "size": -1,
                "width": 2304,
                "height": 1728
            },
            "dariusz-sankowski-dvK_CT1Wg78-unsplash-60.webp": {
                "format": "webp",
                "size": -1,
                "width": 2765,
                "height": 2074
            },
            "dariusz-sankowski-dvK_CT1Wg78-unsplash-70.webp": {
                "format": "webp",
                "size": -1,
                "width": 3226,
                "height": 2420
            },
            "dariusz-sankowski-dvK_CT1Wg78-unsplash-80.webp": {
                "format": "webp",
                "size": -1,
                "width": 3686,
                "height": 2765
            },
            "dariusz-sankowski-dvK_CT1Wg78-unsplash-90.webp": {
                "format": "webp",
                "size": -1,
                "width": 4147,
                "height": 3110
            }
        }
    }
}

Release History

  • 1.0.0
    • Plugin now serves images properly in dev
    • Every folder containing an image will be mounted automatically to serve images properly
  • 0.7.0
    • plugin runs on both (build && dev) processes.
  • 0.4.0
    • added generateImagesOnDev Option to skip image generation during build --watch
    • moved image_sizes.json.json to root folder
    • calculates image sizes on build --watch rather than compiling the files
    • simplified default option setup
  • 0.3.0
    • added a jsonOutput to simplify the dynamic usage
  • 0.2.3
    • switched from transform() to load()
    • added a defaultFormat option for the source image
  • 0.2.1
    • Running only on build process w/o Errors
  • 0.1.0
    • First working example
  • 0.0.3
    • init

Meta

Christoph Luig – @emailwww.0nce.de

Distributed under the MIT license. See LICENSE for more information.

cluigDE

Inspired by

mahnunchik

jaredLunde

Both wrote amazing plugins, which helped me to create this library.

Contributing

  1. Fork it (https://github.com/yourname/yourproject/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request