Skip to content

Plugin for webpack that converts your images to next gen image formats (JPEG-XL, AVIF, WebP) and puts them in a picture element with fallback to a well supported format (JPEG, PNG or GIF).

License

Notifications You must be signed in to change notification settings

mauriciabad/next-gen-images-webpack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

next-gen-images-webpack-plugin

⚠️ DISCLAIMER: This plugin is still in development, for any bugs/requests open issues and PRs.

This plugin transforms <img> tags with images in jpg, jpeg and png to a <picture> tag with the original one and it's version in jxl and webp formats.

<!-- INPUT -->
<img src="./cat.jpg" alt="Cat" />

<!-- OUTPUT -->
<picture>
  <source srcset="cat.jxl" type="image/jxl">
  <source srcset="cat.webp" type="image/webp">
  <img src="cat.jpg" alt="Cat">
</picture>

Installation

npm:

npm install next-gen-images-webpack-plugin --save-dev

Yarn:

yarn add -D next-gen-images-webpack-plugin

You also need webpack 5 and html-webpack-plugin

Usage

Setting up webpack.config.js

const NextGenImagesWebpackPlugin = require('next-gen-images-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
  // other options...

  plugins: [
    // other plugins...
    new HtmlWebpackPlugin(
      // Your HtmlWebpackPlugin custom config
    ),
    new NextGenImagesWebpackPlugin(),
    // other plugins...
  ],
}

Plugin options

For now, it doesn't have any options.

Authors

Maurici Abad Gutierrez - @mauriciabad - https://mauriciabad.com

About

Plugin for webpack that converts your images to next gen image formats (JPEG-XL, AVIF, WebP) and puts them in a picture element with fallback to a well supported format (JPEG, PNG or GIF).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published