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