0.0.7 • Published 5 years ago

rollup-plugin-sharp v0.0.7

Weekly downloads
6
License
MIT
Repository
-
Last release
5 years ago

rollup-plugin-sharp

A rollup plugin which scales and moves images to enable gatsby-image-like image lazy-loading

Usage

Config

import sharp from 'rollup-plugin-sharp'

export default {
    ...
    plugins: [
        ...
        sharp({
            include: ["**/*.jpg"], // defaults to .png, .jpg and .gif files
            fileName: "[hash][extname]" // defaults to [name].[hash][extname]
        })
    ]
}

Import

import image from "./image.jpg";

console.log(image.src); // public url to image i.e: image.ff84eb7eb7196ae2.jpg
console.log(image.placeholder); // data-url placeholder image, i.e: data:image/png;base64,iVBORw0KGgoAAAANSUhEU...
console.log(image.width); // height of the image in pixels, i.e 1024
console.log(image.height); // width of the image in pixels, i.e 1024

Options

NameTypeDescription
includestring \| RegExp \| (string \| RegExp)[]files to include
excludestring \| RegExp \| (string \| RegExp)[]files to exclude
publicPathstringpublic path for the src attribute
destDirstringdestination of the processed image files
minifiedWidthstringwidth of the minified placeholder image
fileNamestringtemplate for the exported file names, accepts [name], [hash] and [extname]
0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago