From 37c898dcb6c6f071d6c8c2d118d20938fb471f36 Mon Sep 17 00:00:00 2001 From: Hrishikesh Kokate Date: Tue, 29 Jul 2025 16:52:31 +0530 Subject: [PATCH 1/2] restore NETLIFY_NEXT_PLUGIN_SKIP --- src/index.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/index.ts b/src/index.ts index ce109ef501..4f6eaac0ce 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,9 +24,16 @@ import { verifyPublishDir, } from './build/verification.js' +const skipPlugin = process.env.NETLIFY_NEXT_PLUGIN_SKIP === 'true' || process.env.NETLIFY_NEXT_PLUGIN_SKIP === '1' +const skipText = 'Skipping Next.js plugin due to NETLIFY_NEXT_PLUGIN_SKIP environment variable.' const tracer = wrapTracer(trace.getTracer('Next.js runtime')) export const onPreDev = async (options: NetlifyPluginOptions) => { + if (skipPlugin) { + console.warn(skipText) + return + } + await tracer.withActiveSpan('onPreDev', async () => { const context = new PluginContext(options) @@ -36,6 +43,11 @@ export const onPreDev = async (options: NetlifyPluginOptions) => { } export const onPreBuild = async (options: NetlifyPluginOptions) => { + if (skipPlugin) { + console.warn(skipText) + return + } + await tracer.withActiveSpan('onPreBuild', async () => { // Enable Next.js standalone mode at build time process.env.NEXT_PRIVATE_STANDALONE = 'true' @@ -53,6 +65,11 @@ export const onPreBuild = async (options: NetlifyPluginOptions) => { } export const onBuild = async (options: NetlifyPluginOptions) => { + if (skipPlugin) { + console.warn(skipText) + return + } + await tracer.withActiveSpan('onBuild', async (span) => { const ctx = new PluginContext(options) @@ -86,12 +103,22 @@ export const onBuild = async (options: NetlifyPluginOptions) => { } export const onPostBuild = async (options: NetlifyPluginOptions) => { + if (skipPlugin) { + console.warn(skipText) + return + } + await tracer.withActiveSpan('onPostBuild', async () => { await publishStaticDir(new PluginContext(options)) }) } export const onSuccess = async () => { + if (skipPlugin) { + console.warn(skipText) + return + } + await tracer.withActiveSpan('onSuccess', async () => { const prewarm = [process.env.DEPLOY_URL, process.env.DEPLOY_PRIME_URL, process.env.URL].filter( // If running locally then the deploy ID is a placeholder value. Filtering for `https://0--` removes it. @@ -102,6 +129,11 @@ export const onSuccess = async () => { } export const onEnd = async (options: NetlifyPluginOptions) => { + if (skipPlugin) { + console.warn(skipText) + return + } + await tracer.withActiveSpan('onEnd', async () => { await unpublishStaticDir(new PluginContext(options)) }) From 5a1df9b52c624eb2faaeff0991a26019806fc130 Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Wed, 30 Jul 2025 15:57:32 +0200 Subject: [PATCH 2/2] chore: fix lint --- src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 4f6eaac0ce..27d9c1ff7b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,7 +24,8 @@ import { verifyPublishDir, } from './build/verification.js' -const skipPlugin = process.env.NETLIFY_NEXT_PLUGIN_SKIP === 'true' || process.env.NETLIFY_NEXT_PLUGIN_SKIP === '1' +const skipPlugin = + process.env.NETLIFY_NEXT_PLUGIN_SKIP === 'true' || process.env.NETLIFY_NEXT_PLUGIN_SKIP === '1' const skipText = 'Skipping Next.js plugin due to NETLIFY_NEXT_PLUGIN_SKIP environment variable.' const tracer = wrapTracer(trace.getTracer('Next.js runtime'))