Skip to content

Commit 37c898d

Browse files
authored
restore NETLIFY_NEXT_PLUGIN_SKIP
1 parent e7318fd commit 37c898d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/index.ts

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

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

2931
export const onPreDev = async (options: NetlifyPluginOptions) => {
32+
if (skipPlugin) {
33+
console.warn(skipText)
34+
return
35+
}
36+
3037
await tracer.withActiveSpan('onPreDev', async () => {
3138
const context = new PluginContext(options)
3239

@@ -36,6 +43,11 @@ export const onPreDev = async (options: NetlifyPluginOptions) => {
3643
}
3744

3845
export const onPreBuild = async (options: NetlifyPluginOptions) => {
46+
if (skipPlugin) {
47+
console.warn(skipText)
48+
return
49+
}
50+
3951
await tracer.withActiveSpan('onPreBuild', async () => {
4052
// Enable Next.js standalone mode at build time
4153
process.env.NEXT_PRIVATE_STANDALONE = 'true'
@@ -53,6 +65,11 @@ export const onPreBuild = async (options: NetlifyPluginOptions) => {
5365
}
5466

5567
export const onBuild = async (options: NetlifyPluginOptions) => {
68+
if (skipPlugin) {
69+
console.warn(skipText)
70+
return
71+
}
72+
5673
await tracer.withActiveSpan('onBuild', async (span) => {
5774
const ctx = new PluginContext(options)
5875

@@ -86,12 +103,22 @@ export const onBuild = async (options: NetlifyPluginOptions) => {
86103
}
87104

88105
export const onPostBuild = async (options: NetlifyPluginOptions) => {
106+
if (skipPlugin) {
107+
console.warn(skipText)
108+
return
109+
}
110+
89111
await tracer.withActiveSpan('onPostBuild', async () => {
90112
await publishStaticDir(new PluginContext(options))
91113
})
92114
}
93115

94116
export const onSuccess = async () => {
117+
if (skipPlugin) {
118+
console.warn(skipText)
119+
return
120+
}
121+
95122
await tracer.withActiveSpan('onSuccess', async () => {
96123
const prewarm = [process.env.DEPLOY_URL, process.env.DEPLOY_PRIME_URL, process.env.URL].filter(
97124
// 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 () => {
102129
}
103130

104131
export const onEnd = async (options: NetlifyPluginOptions) => {
132+
if (skipPlugin) {
133+
console.warn(skipText)
134+
return
135+
}
136+
105137
await tracer.withActiveSpan('onEnd', async () => {
106138
await unpublishStaticDir(new PluginContext(options))
107139
})

0 commit comments

Comments
 (0)