gulp-avif-css

1.0.5 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i gulp-avif-css

Weekly Downloads

3

Version

1.0.5

License

MIT

Unpacked Size

5.71 kB

Total Files

4

Last publish

Collaborators

  • dx1ded