Skip to content

Set encoding to false to prevent image corruption #95

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

Merged
merged 2 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tasks/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ module.exports = (gulp, plugins, sake) => {
})
}

return gulp.src(paths, { base: sake.config.paths.src, allowEmpty: true })
// encoding: false is required because otherwise images will become corrupted
// @link https://github.com/gulpjs/gulp/issues/2790
return gulp.src(paths, { base: sake.config.paths.src, allowEmpty: true, encoding: false })
.pipe(filter)
.pipe(plugins.replace(/\/\*# sourceMappingURL=.*?\*\/$/mg, '')) // remove source mapping references - TODO: consider skipping sourcemaps in compilers instead when running build/deploy tasks
.pipe(plugins.replace('\n', '')) // remove an extra line added by libsass/node-sass
Expand Down
2 changes: 1 addition & 1 deletion tasks/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = (gulp, plugins, sake) => {
return gulp.src([
`${sake.config.paths.build}/${sake.config.plugin.id}/**`,
`!${sake.config.paths.build}/${sake.config.plugin.id}/**/*.zip`
], { nodir: true, base: sake.config.paths.build }) // exclude empty directories, include plugin dir in zip
], { nodir: true, base: sake.config.paths.build, encoding: false }) // exclude empty directories, include plugin dir in zip, no encoding because it breaks images
.pipe(plugins.zip(zipFileName))
.pipe(gulp.dest(sake.config.paths.zipDest))
})
Expand Down