Skip to content

Commit

Permalink
Check if '${out}/prerendered' exists, before precompressing (#1806)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjon authored Jul 3, 2021
1 parent 358d790 commit c639586
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-suits-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-node': patch
---

Check if '[out]/prerendered' exists, before precompressing
17 changes: 12 additions & 5 deletions packages/adapter-node/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { readFileSync, statSync, createReadStream, createWriteStream, writeFileSync } from 'fs';
import esbuild from 'esbuild';
import {
createReadStream,
createWriteStream,
existsSync,
readFileSync,
statSync,
writeFileSync
} from 'fs';
import { join } from 'path';
import { fileURLToPath } from 'url';
import { pipeline } from 'stream';
import glob from 'tiny-glob';
import { fileURLToPath } from 'url';
import { promisify } from 'util';
import zlib from 'zlib';
import esbuild from 'esbuild';
import glob from 'tiny-glob';

const pipe = promisify(pipeline);

Expand Down Expand Up @@ -65,7 +72,7 @@ export default function ({
await utils.prerender({
dest: `${out}/prerendered`
});
if (precompress) {
if (precompress && existsSync(`${out}/prerendered`)) {
utils.log.minor('Compressing prerendered pages');
await compress(`${out}/prerendered`);
}
Expand Down

0 comments on commit c639586

Please sign in to comment.