Skip to content

Node module for optimizing images for web applications

License

Notifications You must be signed in to change notification settings

LupCode/node-lup-images

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub package.json version npm bundle size GitHub Workflow Status NPM

lup-images

Node module for optimizing images in web applications.

Example Server

const { ImagesRequestHandler } = require('lup-images');
const express = require('express');

const app = express();

app.use('/images/*', ImagesRequestHandler());

app.listen();

Example JSX

<OptimizedImage src="https://picsum.photos/200/300" width={200} height={300} />

For NextJS

To work with NextJS you need to add the following to your next.config.js:

experimental: {
    serverComponentsExternalPackages: ["sharp"],
}

Prerender Images before Deployment

Images can also be prerendered before deployment e.g. inside of a CI/CD pipeline. Create a file that contains the following code:

import { PrerenderImages } from 'lup-images';

// this wrapper is needed if you are in the main file of a node project
(async () => {

    // prerender images (provide same options as in the request handler)
    await PrerenderImages({ ... });

})();

In the CI/CD pipeline or wherever you want to prerender the images, run the file using node.

About

Node module for optimizing images for web applications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published