Hello, everyone! I have built a site using Hugo + Gulp, attached NetlifyCMS and moved to Netlify.
This site contains about 100 images and they are all processed with gulp-responsive to save space and add webp support. Everything works great, but small but:
Each time I do even small text change using NetlifyCMS or locally, the build script processing all images I have and increasing build time much. Locally using gulp-newer helps me, but on netlify servers such feature doesn’t work. I’ve read that there is undocumented folder in netlify “/opt/build/cache/”, but it haven’t helped me a lot. Maybe I missing something. Any advice would be appreciated. Thanks a lot for your time!
gulp.task('images-prod', () => {
return gulp.src('/opt/build/cache/assets/images/*.{jpg,jpeg,png}')
.pipe(newer('/assets/images/public'))
.pipe(responsive({
'**/*.{jpg,png,jpeg}': [{
width: 2000,
quality: 75,
compressionLevel: 7,
}, {
width: 2000,
quality: 75,
rename: {
extname: '.webp',
},
}],
}, {
errorOnEnlargement: false,
errorOnUnusedConfig: false
}))
.pipe(rename(function(opt) {
opt.basename = opt.basename.split(' ').join('_');
return opt;
}))
.pipe(gulp.dest('/assets/images/public/'));
});
gulp.task('hugo-build', shell.task(['hugo']))
gulp.task('build', gulp.series('minify-js', 'hugo-build', 'images-prod', 'minify-html'));