File tree 1 file changed +16
-15
lines changed
1 file changed +16
-15
lines changed Original file line number Diff line number Diff line change @@ -29,23 +29,24 @@ module.exports = {
29
29
return failBuild ( 'Could not find a package.json for this project' )
30
30
}
31
31
32
- const nextConfig = await getNextConfig ( utils . failBuild )
33
- await restoreCache ( { cache : utils . cache , distDir : nextConfig . distDir } )
34
-
35
- if ( await doesNotNeedPlugin ( { netlifyConfig, packageJson, failBuild } ) ) {
36
- return
32
+ const pluginNotNeeded = await doesNotNeedPlugin ( { netlifyConfig, packageJson, failBuild } )
33
+
34
+ if ( ! pluginNotNeeded ) {
35
+ const nextConfigPath = await findUp ( 'next.config.js' )
36
+ if ( nextConfigPath === undefined ) {
37
+ // Create the next config file with target set to serverless by default
38
+ const nextConfig = `
39
+ module.exports = {
40
+ target: 'serverless'
41
+ }
42
+ `
43
+ await pWriteFile ( 'next.config.js' , nextConfig )
44
+ }
37
45
}
38
46
39
- const nextConfigPath = await findUp ( 'next.config.js' )
40
- if ( nextConfigPath === undefined ) {
41
- // Create the next config file with target set to serverless by default
42
- const nextConfig = `
43
- module.exports = {
44
- target: 'serverless'
45
- }
46
- `
47
- await pWriteFile ( 'next.config.js' , nextConfig )
48
- }
47
+ // Because we memoize nextConfig, we need to do this after the write file
48
+ const nextConfig = await getNextConfig ( utils . failBuild )
49
+ await restoreCache ( { cache : utils . cache , distDir : nextConfig . distDir } )
49
50
} ,
50
51
async onBuild ( {
51
52
netlifyConfig,
You can’t perform that action at this time.
0 commit comments