Skip to content

Commit

Permalink
Update publicFiles checking in next build
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Sep 16, 2019
1 parent 7e5671b commit 3a73e64
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,17 @@ export default async function build(dir: string, conf = null): Promise<void> {
const distDir = path.join(dir, config.distDir)
const pagesDir = path.join(dir, 'pages')
const publicDir = path.join(dir, 'public')
let publicFiles = await recursiveReadDir(publicDir, /.*/)
let publicFiles: string[] = []
let hasPublicDir = false

try {
await fsStat(publicDir)
hasPublicDir = true
} catch (_) {}

if (hasPublicDir) {
publicFiles = await recursiveReadDir(publicDir, /.*/)
}

let tracer: any = null
if (config.experimental.profiling) {
Expand All @@ -108,10 +118,12 @@ export default async function build(dir: string, conf = null): Promise<void> {
const entrypoints = createEntrypoints(mappedPages, target, buildId, config)
const conflictingPublicFiles: string[] = []

try {
await fsStat(path.join(publicDir, '_next'))
throw new Error(PUBLIC_DIR_MIDDLEWARE_CONFLICT)
} catch (err) {}
if (hasPublicDir) {
try {
await fsStat(path.join(publicDir, '_next'))
throw new Error(PUBLIC_DIR_MIDDLEWARE_CONFLICT)
} catch (err) {}
}

for (let file of publicFiles) {
file = file
Expand Down

0 comments on commit 3a73e64

Please sign in to comment.