Skip to content

Commit 182b683

Browse files
authored
Merge branch 'main' into feat/node-middleware-support
2 parents 2203640 + 0b51c47 commit 182b683

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/index.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,17 @@ import {
2424
verifyPublishDir,
2525
} from './build/verification.js'
2626

27+
const skipPlugin =
28+
process.env.NETLIFY_NEXT_PLUGIN_SKIP === 'true' || process.env.NETLIFY_NEXT_PLUGIN_SKIP === '1'
29+
const skipText = 'Skipping Next.js plugin due to NETLIFY_NEXT_PLUGIN_SKIP environment variable.'
2730
const tracer = wrapTracer(trace.getTracer('Next.js runtime'))
2831

2932
export const onPreDev = async (options: NetlifyPluginOptions) => {
33+
if (skipPlugin) {
34+
console.warn(skipText)
35+
return
36+
}
37+
3038
await tracer.withActiveSpan('onPreDev', async () => {
3139
const context = new PluginContext(options)
3240

@@ -36,6 +44,11 @@ export const onPreDev = async (options: NetlifyPluginOptions) => {
3644
}
3745

3846
export const onPreBuild = async (options: NetlifyPluginOptions) => {
47+
if (skipPlugin) {
48+
console.warn(skipText)
49+
return
50+
}
51+
3952
await tracer.withActiveSpan('onPreBuild', async () => {
4053
// Enable Next.js standalone mode at build time
4154
process.env.NEXT_PRIVATE_STANDALONE = 'true'
@@ -53,6 +66,11 @@ export const onPreBuild = async (options: NetlifyPluginOptions) => {
5366
}
5467

5568
export const onBuild = async (options: NetlifyPluginOptions) => {
69+
if (skipPlugin) {
70+
console.warn(skipText)
71+
return
72+
}
73+
5674
await tracer.withActiveSpan('onBuild', async (span) => {
5775
const ctx = new PluginContext(options)
5876

@@ -86,12 +104,22 @@ export const onBuild = async (options: NetlifyPluginOptions) => {
86104
}
87105

88106
export const onPostBuild = async (options: NetlifyPluginOptions) => {
107+
if (skipPlugin) {
108+
console.warn(skipText)
109+
return
110+
}
111+
89112
await tracer.withActiveSpan('onPostBuild', async () => {
90113
await publishStaticDir(new PluginContext(options))
91114
})
92115
}
93116

94117
export const onSuccess = async () => {
118+
if (skipPlugin) {
119+
console.warn(skipText)
120+
return
121+
}
122+
95123
await tracer.withActiveSpan('onSuccess', async () => {
96124
const prewarm = [process.env.DEPLOY_URL, process.env.DEPLOY_PRIME_URL, process.env.URL].filter(
97125
// If running locally then the deploy ID is a placeholder value. Filtering for `https://0--` removes it.
@@ -102,6 +130,11 @@ export const onSuccess = async () => {
102130
}
103131

104132
export const onEnd = async (options: NetlifyPluginOptions) => {
133+
if (skipPlugin) {
134+
console.warn(skipText)
135+
return
136+
}
137+
105138
await tracer.withActiveSpan('onEnd', async () => {
106139
await unpublishStaticDir(new PluginContext(options))
107140
})

tests/utils/fixture.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ import { BLOB_TOKEN } from './constants.mjs'
3232
import { type FixtureTestContext } from './contexts.js'
3333
import { setNextVersionInFixture } from './next-version-helpers.mjs'
3434

35-
const bootstrapURL = 'https://edge.netlify.com/bootstrap/index-combined.ts'
35+
const bootstrapURL =
36+
'https://6877afcf20679a00086bab1c--edge.netlify.com/bootstrap/index-combined.ts'
3637
const actualCwd = await vi.importActual<typeof import('process')>('process').then((p) => p.cwd())
3738
const eszipHelper = join(actualCwd, 'tools/deno/eszip.ts')
3839

0 commit comments

Comments
 (0)