Skip to content

Commit 7e2c892

Browse files
committed
chore: Revert "chore: NETLIFY_NEXT_PLUGIN_SKIP is now handled by builds"
This reverts commit ba13f81.
1 parent ba13f81 commit 7e2c892

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/index.ts

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

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

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

@@ -37,6 +45,11 @@ export const onPreDev = async (options: NetlifyPluginOptions) => {
3745
}
3846

3947
export const onPreBuild = async (options: NetlifyPluginOptions) => {
48+
if (skipPlugin) {
49+
console.warn(skipText)
50+
return
51+
}
52+
4053
await tracer.withActiveSpan('onPreBuild', async (span) => {
4154
// Enable Next.js standalone mode at build time
4255
process.env.NEXT_PRIVATE_STANDALONE = 'true'
@@ -55,6 +68,11 @@ export const onPreBuild = async (options: NetlifyPluginOptions) => {
5568
}
5669

5770
export const onBuild = async (options: NetlifyPluginOptions) => {
71+
if (skipPlugin) {
72+
console.warn(skipText)
73+
return
74+
}
75+
5876
await tracer.withActiveSpan('onBuild', async (span) => {
5977
const ctx = new PluginContext(options)
6078

@@ -88,12 +106,22 @@ export const onBuild = async (options: NetlifyPluginOptions) => {
88106
}
89107

90108
export const onPostBuild = async (options: NetlifyPluginOptions) => {
109+
if (skipPlugin) {
110+
console.warn(skipText)
111+
return
112+
}
113+
91114
await tracer.withActiveSpan('onPostBuild', async () => {
92115
await publishStaticDir(new PluginContext(options))
93116
})
94117
}
95118

96119
export const onSuccess = async () => {
120+
if (skipPlugin) {
121+
console.warn(skipText)
122+
return
123+
}
124+
97125
await tracer.withActiveSpan('onSuccess', async () => {
98126
const prewarm = [process.env.DEPLOY_URL, process.env.DEPLOY_PRIME_URL, process.env.URL].filter(
99127
// If running locally then the deploy ID is a placeholder value. Filtering for `https://0--` removes it.
@@ -104,6 +132,11 @@ export const onSuccess = async () => {
104132
}
105133

106134
export const onEnd = async (options: NetlifyPluginOptions) => {
135+
if (skipPlugin) {
136+
console.warn(skipText)
137+
return
138+
}
139+
107140
await tracer.withActiveSpan('onEnd', async () => {
108141
await unpublishStaticDir(new PluginContext(options))
109142
})

0 commit comments

Comments
 (0)