Skip to content

Gulp v5 corrupt font files #2797

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
gwicksted opened this issue Apr 25, 2024 · 5 comments
Closed

Gulp v5 corrupt font files #2797

gwicksted opened this issue Apr 25, 2024 · 5 comments

Comments

@gwicksted
Copy link

What were you expecting to happen?

Gulp copies the binary files verbatim

What actually happened?

Contents of the files were modified with unicode placeholders.

Please give us a sample of your gulpfile

var gulp = require("gulp");

gulp.task("copy-fonts", () => {
    return gulp.src("Content/fonts/**/*.*")
        .pipe(gulp.dest("bin/Content/fonts"));
});

Terminal output / screenshots

$ npx gulp copy-fonts

Please provide the following information:

  • OS & version [e.g. MacOS Catalina 10.15.4]: Windows 10
  • node version (run node -v): v20.12.1
  • npm version (run npm -v): 10.5.2
  • gulp version (run gulp -v): CLI version: 3.0.0
    Local version: 5.0.0

Additional information

Switching back to gulp 4.0.2 fixes the issue (files are binary identical).

npm i gulp@4 --save-dev

Switching back to gulp 5.0.0 reproduces the issue.

npm i gulp@5 --save-dev

The source .woff file started with:

00000000: 77 4F 46 46 00 01 00 00
00000008: 00 01 82 F8
0000000C: 00 12 00 00 00 03 4F 38

With gulp v5, the bin copy of the .woff file starts with:

00000000: 77 4F 46 46 00 01 00 00
00000008: 00 01 EF BF BD EF BF BD
00000010: 00 12 00 00 00 03 4F 38

(there are many more instances of that Unicode escape sequence in the woff file)

Troubleshooting

Tried specifying { encoding: "binary" } in the gulp.src call but that just changes bytes in different ways. (this variation also works as expected in gulp v4 but not in v5)

Below is the output from gulp v5:

00000000: 77 4F 46 46 00 01 00 00
00000008: 00 01 C2 82 C3 B8 00 12
00000010: 00 00 00 03 4F 38 00 06
@shuguroff
Copy link

Same issue with images and fonts

@KikelDmitry
Copy link

KikelDmitry commented Apr 29, 2024

Had a same issue. Fixed it like this ({encoding: false} as arg in src):

import { src, dest } from 'gulp';

const fonts = () => {
	return src('source-path', { encoding: false }).pipe(dest('destination-path'))
};

@ryanlelek
Copy link

Thank you @KikelDmitry , confirmed working with your fix

@yocontra
Copy link
Member

yocontra commented May 3, 2024

Dupe of other open tickets, closing. Docs in the docs folder and release blog post have this but website needs to be updated still.

@yocontra yocontra closed this as completed May 3, 2024
@phated
Copy link
Member

phated commented May 4, 2024

The website is updated now.

the-djmaze pushed a commit to the-djmaze/snappymail that referenced this issue Aug 12, 2024
amercader added a commit to ckan/ckan that referenced this issue Feb 12, 2025
There was a change in gulp 5 that defaulted the stream encoding to
UTF8. To preserve binary files like fonts you need to
pass `{encoding: false}`

Reference:

gulpjs/gulp#2797
wardi pushed a commit to ckan/ckan that referenced this issue Mar 19, 2025
There was a change in gulp 5 that defaulted the stream encoding to
UTF8. To preserve binary files like fonts you need to
pass `{encoding: false}`

Reference:

gulpjs/gulp#2797
amercader added a commit to ckan/ckan that referenced this issue Apr 24, 2025
There was a change in gulp 5 that defaulted the stream encoding to
UTF8. To preserve binary files like fonts you need to
pass `{encoding: false}`

Reference:

gulpjs/gulp#2797
duttonw pushed a commit to qld-gov-au/ckan that referenced this issue May 14, 2025
There was a change in gulp 5 that defaulted the stream encoding to
UTF8. To preserve binary files like fonts you need to
pass `{encoding: false}`

Reference:

gulpjs/gulp#2797
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

6 participants