diff --git a/.changeset/few-suits-flash.md b/.changeset/few-suits-flash.md new file mode 100644 index 000000000000..f7e48a2392e3 --- /dev/null +++ b/.changeset/few-suits-flash.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-node': patch +--- + +Check if '[out]/prerendered' exists, before precompressing diff --git a/packages/adapter-node/index.js b/packages/adapter-node/index.js index 57a4a4c5b429..2d527c4d6b80 100644 --- a/packages/adapter-node/index.js +++ b/packages/adapter-node/index.js @@ -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); @@ -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`); }