Skip to content

A Gulp plugin that allows to generate additional `.webp` and `.avif` classes for images depending on browser support

Notifications You must be signed in to change notification settings

dx1ded/gulp-avif-css

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-avif-css

Generates additional .webp & .avif classes for loading a specific image if it's supported by the browser

Usage

Install gulp-avif-css:

npm install -D gulp-avif-css

Add it to your gulpfile.js

const gulp = require("gulp")
const avifcss = require("gulp-avif-css")

gulp.src("./src/css/*.css")
  .pipe(avifcss())
  .pipe(gulp.dest("./dist"))

Include the special plugin which adds .avif and .webp classes for <body> (if it's supported) into a JavaScript file and load it in <head> tag

import "gulp-avif-css/plugin"

Examples

Input:

.box {
    background-image: url("image.png");
}

Output:

.box {
    background-image: url("image.png");
}

.webp .box {
    background-image: url("image.webp");
}

.avif .box {
    background-image: url("image.avif");
}

Parameters

extensions

Type: Array
Default: ["png", "jpg", "jpeg", "JPG", "JPEG"]

Sets extensions that are going to be targeted by the plugin

About

A Gulp plugin that allows to generate additional `.webp` and `.avif` classes for images depending on browser support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published