diff --git a/packages/runtime/src/helpers/dev.ts b/packages/runtime/src/helpers/dev.ts index fea2b24aa5..3665027d1d 100644 --- a/packages/runtime/src/helpers/dev.ts +++ b/packages/runtime/src/helpers/dev.ts @@ -19,22 +19,22 @@ export const onPreDev: OnPreBuild = async ({ constants, netlifyConfig }) => { // Ignore if it doesn't exist }) await writeDevEdgeFunction(constants) + if (!existsSync(resolve(base, 'middleware.ts')) && !existsSync(resolve(base, 'middleware.js'))) { console.log( - "No middleware found. Create a 'middleware.ts' or 'middleware.js' file in your project root to add custom middleware.", + "No middleware found. If you did intend to use middleware, create a 'middleware.ts' or 'middleware.js' file in your project root to add custom middleware.", ) } else { console.log('Watching for changes in Next.js middleware...') - } - // Eventually we might want to do this via esbuild's API, but for now the CLI works fine - const common = [`--bundle`, `--outdir=${resolve('.netlify')}`, `--format=esm`, `--target=esnext`, '--watch'] + // Eventually we might want to do this via esbuild's API, but for now the CLI works fine + const common = [`--bundle`, `--outdir=${resolve('.netlify')}`, `--format=esm`, `--target=esnext`, '--watch'] - // TypeScript - execa(`esbuild`, [...common, resolve(base, 'middleware.ts')], { all: true }).all.pipe(process.stdout) + // TypeScript + execa(`esbuild`, [...common, resolve(base, 'middleware.ts')], { all: true }).all.pipe(process.stdout) - // JavaScript - execa(`esbuild`, [...common, resolve(base, 'middleware.js')], { all: true }).all.pipe(process.stdout) - - // Don't return the promise because we don't want to wait for the child process to finish + // JavaScript + execa(`esbuild`, [...common, resolve(base, 'middleware.js')], { all: true }).all.pipe(process.stdout) + // Don't return the promise because we don't want to wait for the child process to finish + } }