gulp icon indicating copy to clipboard operation
gulp copied to clipboard

Images not loading after build gulp, when version changed (4.0.2 -> 5.0.0)

Open tasnim2512 opened this issue 2 years ago • 3 comments

I'm encountering an issue where images are not loading after running the Gulp build process. The images are copied to the dist/assets/images directory, but when I try to load the website in a browser, it shows a "image cannot load" error when inspect the image.Also on the dist folder i can see the image files but can not open them while it was working when i used gulp4.0.2. Js and css files are working fine.

Expected Behavior: The images should load correctly in the browser, being served from the dist/assets/images directory.

Actual Behavior: The browser shows no image.

gulpfile.js

const paths = {   
 dist: {
        img: {
            dir: './dist/assets/images',
        },
    },
 src: {
        img: {
            dir: './src/assets/images',
            files: './src/assets/images/**/*',
        },
    }
gulp.task('copy:images', function () {
    return gulp
        .src(paths.src.img.files)
        .pipe(gulp.dest(paths.dist.img.dir));
});

gulp.task('default', gulp.series(gulp.parallel('copy:images'), gulp.parallel('browsersync', 'watch')));

gulp.task('build', gulp.series('copy:images'));

Os & versions

  • OS & version-Ubuntu 22.04.4 LTS
  • node version :18.20.2
  • npm version: 10.5.0
  • gulp version: CLI version: 3.0.0 Local version: 5.0.0

Screenshots

Screenshot from 2024-07-29 18-35-09 Screenshot from 2024-07-29 18-26-06

tasnim2512 avatar Jul 29 '24 12:07 tasnim2512

.src(paths.src.img.files) -> .src(paths.src.img.files, { encoding: false }) - See release notes for v5 that document this change.

yocontra avatar Jul 29 '24 16:07 yocontra

Hello @yocontra Thank you for the solution but it's still not working on my end.Am i missing something?

gulp.task('copy:images', function () {
    return gulp
        .src(paths.src.img.files, { encoding: false })
        .pipe(gulp.dest(paths.dist.img.dir));
});

I am sharing my whole gulpfile here. https://drive.google.com/file/d/11iZnagRCpVw4Bzj24ck3xl7JGE0aLMxm/view?usp=drive_link

tasnim2512 avatar Jul 30 '24 10:07 tasnim2512

I join the issue. Adding a parameter does not solve the problem.

NodeJS: 22.13.1 CLI version: 3.0.0 Local version: 5.0.0 OS: macOS Big Sure 11.7.10

` import ttf2woff from 'gulp-ttf2woff';

export const ttfToWoff = async () => { const ttf2woff2 = await import('gulp-ttf2woff2');

return app.gulp.src(`${app.path.srcFolder}/fonts/*.ttf`, {encoding: false})
	.pipe(app.plugins.plumber({
		errorHandler: function (err) {
			console.log(err)
			this.emit('end');
		}
	}))
	.pipe(ttf2woff())
	.pipe(app.gulp.dest(`${app.path.build.fonts}`))
	.pipe(app.gulp.src(`${app.path.srcFolder}/fonts/*.ttf`), {encoding: false})
	.pipe(ttf2woff2.default())
	.pipe(app.gulp.dest(`${app.path.build.fonts}`));

} `

Daniil-333 avatar Jan 30 '25 14:01 Daniil-333