Skip to content

Commit

Permalink
Compress EPUB, fixes #169
Browse files Browse the repository at this point in the history
  • Loading branch information
danburzo committed May 6, 2024
1 parent 8398032 commit 8c40941
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,10 @@ async function epubgen(data, output_path, options) {

const output = fs.createWriteStream(output_path);
const archive = archiver('zip', {
store: true
zlib: {
// Best DEFLATE compression level
level: 9
}
});

output
Expand All @@ -833,7 +836,11 @@ async function epubgen(data, output_path, options) {
archive.on('warning', reject).on('error', reject).pipe(output);

// mimetype file must be first
archive.append('application/epub+zip', { name: 'mimetype' });
archive.append('application/epub+zip', {
name: 'mimetype',
// don’t compress the mimetype file as per EPUB spec
store: true
});

// static files from META-INF
archive.directory(path.join(template_base, 'META-INF'), 'META-INF');
Expand Down

0 comments on commit 8c40941

Please sign in to comment.