Skip to content

Gulp.src/gulp.dest does not copy images or fonts correctly in [email protected] #2796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
marcelotena opened this issue Apr 18, 2024 · 3 comments

Comments

@marcelotena
Copy link

What were you expecting to happen?

Wrote a task to optimize images using gulp-imagemin and move compressed files to a destination folder.

What actually happened?

Files did not compress and moved files could not be opened. I can see that it also happens when fonts are moved using gulp.src/gulp.dest, resulting files can't be opened.

Everything works correctly if I roll back to version 4.0.2.

Please give us a sample of your gulpfile

Here's a link to my gulpfile: https://github.com/marcelotena/gulp-frontend-starter/blob/main/gulpfile.babel.js

-->

import gulp from 'gulp'
import {default as imagemin, gifsicle, mozjpeg, optipng} from 'gulp-imagemin'

gulp.task('imgmin', () => {
    return gulp.src('./src/img/*')
        .pipe(imagemin([
            gifsicle({interlaced: true}),
            mozjpeg({quality: 60, progressive: true}),
            optipng({optimizationLevel: 5})
        ]))
        .pipe(gulp.dest('./dist/img'));
});

Terminal output / screenshots

No issues are displayed in the terminal.

Please provide the following information:

  • OS & version: macOS 12.2.1
  • node version (run node -v): 21.7.3
  • npm version (run npm -v): 10.5.0
  • gulp version (run gulp -v): 5.0.0
@Sebazzz
Copy link

Sebazzz commented Apr 18, 2024

Also happens with a simple gulp.src('./node_modules/material-symbols/*.woff2').pipe(gulp.dest('./wwwroot/build/fonts/')).

The file sizes are different, it appears that the files are incorrectly read or copied:

image

Seems to be some kind of encoding problem, or reading binaries in text mode:

image

@restless
Copy link

restless commented Apr 18, 2024

Please see: #2790

TL;DR
try: .src(path, {encoding: false})

@marcelotena
Copy link
Author

Thank you @restless, setting up encoding to false solves the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants