Skip to content

Commit 85ba5b6

Browse files
committed
Support both manifests for SSR builds
1 parent d0ff05c commit 85ba5b6

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

bin/clean.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22

3-
import { readFileSync, readdirSync, unlinkSync } from 'fs'
3+
import { readFileSync, readdirSync, unlinkSync, existsSync } from 'fs'
44
import { dirname } from 'path'
55

66
/*
@@ -24,7 +24,13 @@ const option = (name) => process.argv.includes(`--${name}`)
2424
const dryRun = option(`dry-run`)
2525
const quiet = option(`quiet`)
2626
const wantsSsr = option('ssr')
27-
const manifestPath = argument(`manifest`, () => wantsSsr ? `./bootstrap/ssr/ssr-manifest.json` : `./public/build/manifest.json`)
27+
const manifestPath = argument(`manifest`, () => {
28+
if (! wantsSsr) {
29+
return `./public/build/manifest.json`
30+
}
31+
32+
return existsSync(`./bootstrap/ssr/ssr-manifest.json`) ? `./bootstrap/ssr/ssr-manifest.json` : `./public/build/manifest.json`
33+
})
2834
const assetsDirectory = argument(`assets`, () => `${dirname(manifestPath)}/assets`)
2935

3036
/*
@@ -46,12 +52,6 @@ const main = () => {
4652

4753
const isSsr = Array.isArray(manifest[manifestKeys[0]])
4854

49-
if (wantsSsr && ! isSsr) {
50-
error('Did not find expected SSR manifest.')
51-
52-
process.exit(1)
53-
}
54-
5555
isSsr
5656
? info(`SSR manifest found.`)
5757
: info(`Non-SSR manifest found.`)

0 commit comments

Comments
 (0)