File tree Expand file tree Collapse file tree 1 file changed +16
-15
lines changed Expand file tree Collapse file tree 1 file changed +16
-15
lines changed Original file line number Diff line number Diff line change @@ -29,23 +29,24 @@ module.exports = {
2929 return failBuild ( 'Could not find a package.json for this project' )
3030 }
3131
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+ }
3745 }
3846
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 } )
4950 } ,
5051 async onBuild ( {
5152 netlifyConfig,
You can’t perform that action at this time.
0 commit comments