Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

html-srcset-loader

icewind19913280.1.1

Automatically add srcset to images in html

readme

html-srcset-loader

Automatically add srcset to images in html

installation

Requires image-resize-loader to create the resized images.

npm install --save-dev loader-utils jimp image-resize-loader html-srcset-loader

Usage

The html-srcset-loader will automatically transform any image in an html document to include an srcset with smaller versions of the image to lower bandwith usage on lower resulution screens.

loaders: [
    {
        test: /.*\.(png|jpg)(\?.+)?$/i,
        loaders: [
            'file',
            'image-resize'
        ]
    },
    {
        test: /\.html$/,
        loader: "html!html-srcset"
    },
    ...
]