File tree Expand file tree Collapse file tree 3 files changed +20
-47
lines changed Expand file tree Collapse file tree 3 files changed +20
-47
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
const getNextConfig = require ( './getNextConfig' )
2
+ const findUp = require ( 'find-up' )
3
+ const { writeFile, unlink } = require ( 'fs-extra' )
4
+ const path = require ( 'path' )
5
+
2
6
// Checks if site has the correct next.config.js
3
7
const verifyBuildTarget = async ( { failBuild } ) => {
4
8
const { target } = await getNextConfig ( failBuild )
@@ -32,6 +36,22 @@ const verifyBuildTarget = async ({ failBuild }) => {
32
36
// Clear memoized cache
33
37
getNextConfig . clear ( )
34
38
39
+ // Temporarily creating a config file, because otherwise Next won't reload the config and pick up the new target
40
+ const hasConfigFile = await Boolean ( findUp ( 'next.config.js' ) )
41
+ const configFileName = path . resolve ( 'next.config.js' )
42
+
43
+ if ( ! hasConfigFile ) {
44
+ await writeFile ( configFileName , `module.exports = {}` )
45
+ }
46
+ // Force the new config to be generated
47
+ await getNextConfig ( failBuild )
48
+
49
+ // If we created a config file then delete it
50
+ if ( ! hasConfigFile ) {
51
+ await unlink ( configFileName )
52
+ }
53
+ // Reset the value in case something else is looking for it
54
+ process . env . NOW_BUILDER = false
35
55
/* eslint-enable fp/no-delete, node/no-unpublished-require */
36
56
}
37
57
You can’t perform that action at this time.
0 commit comments