image optimized
This commit is contained in:
parent
4baf06cbdb
commit
e89197d89c
3237
package-lock.json
generated
3237
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -8,12 +8,17 @@
|
|||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"sass": "sass --watch public/assets/scss/main.scss:public/assets/css/main.css",
|
"sass": "sass --watch public/assets/scss/main.scss:public/assets/css/main.css",
|
||||||
"sitemap": "node scripts/generate-sitemap.cjs"
|
"sitemap": "node scripts/generate-sitemap.cjs",
|
||||||
|
"optimize-images": "node --experimental-modules scripts/optimize-images.mjs",
|
||||||
|
"postbuild": "npm run optimize-images"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.11.0",
|
"axios": "^1.11.0",
|
||||||
"bootstrap-touchspin": "^4.7.3",
|
"bootstrap-touchspin": "^4.7.3",
|
||||||
"framer-motion": "^12.23.12",
|
"framer-motion": "^12.23.12",
|
||||||
|
"imagemin": "^9.0.1",
|
||||||
|
"imagemin-mozjpeg": "^10.0.0",
|
||||||
|
"imagemin-optipng": "^8.0.0",
|
||||||
"isotope-layout": "^3.0.6",
|
"isotope-layout": "^3.0.6",
|
||||||
"lightgallery": "^2.7.2",
|
"lightgallery": "^2.7.2",
|
||||||
"next": "^14.0.4-canary.36",
|
"next": "^14.0.4-canary.36",
|
||||||
|
|||||||
23
scripts/optimize-images.mjs
Normal file
23
scripts/optimize-images.mjs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// scripts/optimize-images.mjs
|
||||||
|
import imagemin from 'imagemin';
|
||||||
|
import imageminMozjpeg from 'imagemin-mozjpeg';
|
||||||
|
import imageminOptipng from 'imagemin-optipng';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
const source = path.join(process.cwd(), 'public/images/*.{jpg,png}');
|
||||||
|
const destination = path.join(process.cwd(), 'public/images-optimized');
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
const files = await imagemin([source], {
|
||||||
|
destination,
|
||||||
|
plugins: [
|
||||||
|
imageminMozjpeg({ quality: 90 }),
|
||||||
|
imageminOptipng({ optimizationLevel: 3 }),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
console.log('Images optimized:', files.map(f => f.destinationPath));
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error optimizing images:', error);
|
||||||
|
}
|
||||||
|
})();
|
||||||
Loading…
x
Reference in New Issue
Block a user