https://github.com/lupcode/node-lup-images
Node module for optimizing images for web applications
https://github.com/lupcode/node-lup-images
Last synced: 3 months ago
JSON representation
Node module for optimizing images for web applications
- Host: GitHub
- URL: https://github.com/lupcode/node-lup-images
- Owner: LupCode
- License: mit
- Created: 2023-05-13T15:45:28.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-27T22:35:39.000Z (over 1 year ago)
- Last Synced: 2025-02-15T00:24:23.896Z (3 months ago)
- Language: JavaScript
- Size: 4.2 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README



# lup-images
Node module for optimizing images in web applications.## Example Server
```javascript
const { ImagesRequestHandler } = require('lup-images');
const express = require('express');const app = express();
app.use('/images/*', ImagesRequestHandler());
app.listen();
```## Example JSX
```jsx```
## For NextJS
To work with NextJS you need to add the following to your `next.config.js`:
```javascript
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:
```typescript
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.