From c9bfba686543c83aff2566495b21e743db8817b2 Mon Sep 17 00:00:00 2001 From: Kevin Donahue Date: Mon, 10 Apr 2017 10:07:38 -0400 Subject: [PATCH] Only watch config file that exists on the level of source files (#1643) --- bin/next | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/next b/bin/next index 8654d788..79f635b7 100755 --- a/bin/next +++ b/bin/next @@ -1,9 +1,10 @@ #!/usr/bin/env node -import { join } from 'path' +import { join, resolve } from 'path' import { spawn } from 'cross-spawn' import { watchFile } from 'fs' import pkg from '../../package.json' +import getConfig from '../server/config' if (pkg.peerDependencies) { Object.keys(pkg.peerDependencies).forEach(dependency => { @@ -78,9 +79,10 @@ const startProcess = () => { } let proc = startProcess() +const { pagesDirectory = resolve(process.cwd(), 'pages') } = getConfig(process.cwd()) if (cmd === 'dev') { - watchFile(join(process.cwd(), 'next.config.js'), (cur, prev) => { + watchFile(`${resolve(pagesDirectory, '..')}/next.config.js`, (cur, prev) => { if (cur.size > 0 || prev.size > 0) { console.log('\n> Found a change in next.config.js, restarting the server...') // Don't listen to 'close' now since otherwise parent gets killed by listener