Skip to content

guilhermehn/koa-accept-webp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-accept-webp

Koa middleware for serving webp images when support is detected

Install

npm install koa-accept-webp

Usage

const Koa = require('koa')
const static = require('koa-static')
const acceptWebp = require('koa-accept-webp')

const app = new Koa()

// Add the acceptWebp middleware before the statics middleware,
// so it can redirect image requests to the webp versions
app.use(acceptWebp(__dirname))
app.use(static(__dirname))
app.listen(1337)

Arguments

acceptWebp(root[, extensions])
Argument Type Description Default Required
root String Statics root directory Yes
extensions Array Extensions that can be served as webp ['jpg', 'jpeg', 'png'] No

License

MIT

About

Koa middleware for serving webp images when support is detected

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%