@@ -24,9 +24,16 @@ import {
24
24
verifyPublishDir ,
25
25
} from './build/verification.js'
26
26
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.'
27
29
const tracer = wrapTracer ( trace . getTracer ( 'Next.js runtime' ) )
28
30
29
31
export const onPreDev = async ( options : NetlifyPluginOptions ) => {
32
+ if ( skipPlugin ) {
33
+ console . warn ( skipText )
34
+ return
35
+ }
36
+
30
37
await tracer . withActiveSpan ( 'onPreDev' , async ( ) => {
31
38
const context = new PluginContext ( options )
32
39
@@ -36,6 +43,11 @@ export const onPreDev = async (options: NetlifyPluginOptions) => {
36
43
}
37
44
38
45
export const onPreBuild = async ( options : NetlifyPluginOptions ) => {
46
+ if ( skipPlugin ) {
47
+ console . warn ( skipText )
48
+ return
49
+ }
50
+
39
51
await tracer . withActiveSpan ( 'onPreBuild' , async ( ) => {
40
52
// Enable Next.js standalone mode at build time
41
53
process . env . NEXT_PRIVATE_STANDALONE = 'true'
@@ -53,6 +65,11 @@ export const onPreBuild = async (options: NetlifyPluginOptions) => {
53
65
}
54
66
55
67
export const onBuild = async ( options : NetlifyPluginOptions ) => {
68
+ if ( skipPlugin ) {
69
+ console . warn ( skipText )
70
+ return
71
+ }
72
+
56
73
await tracer . withActiveSpan ( 'onBuild' , async ( span ) => {
57
74
const ctx = new PluginContext ( options )
58
75
@@ -86,12 +103,22 @@ export const onBuild = async (options: NetlifyPluginOptions) => {
86
103
}
87
104
88
105
export const onPostBuild = async ( options : NetlifyPluginOptions ) => {
106
+ if ( skipPlugin ) {
107
+ console . warn ( skipText )
108
+ return
109
+ }
110
+
89
111
await tracer . withActiveSpan ( 'onPostBuild' , async ( ) => {
90
112
await publishStaticDir ( new PluginContext ( options ) )
91
113
} )
92
114
}
93
115
94
116
export const onSuccess = async ( ) => {
117
+ if ( skipPlugin ) {
118
+ console . warn ( skipText )
119
+ return
120
+ }
121
+
95
122
await tracer . withActiveSpan ( 'onSuccess' , async ( ) => {
96
123
const prewarm = [ process . env . DEPLOY_URL , process . env . DEPLOY_PRIME_URL , process . env . URL ] . filter (
97
124
// 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 () => {
102
129
}
103
130
104
131
export const onEnd = async ( options : NetlifyPluginOptions ) => {
132
+ if ( skipPlugin ) {
133
+ console . warn ( skipText )
134
+ return
135
+ }
136
+
105
137
await tracer . withActiveSpan ( 'onEnd' , async ( ) => {
106
138
await unpublishStaticDir ( new PluginContext ( options ) )
107
139
} )
0 commit comments