Skip to content

Commit af78226

Browse files
committed
fix: create temporary config file
1 parent 0456d6c commit af78226

File tree

3 files changed

+14
-47
lines changed

3 files changed

+14
-47
lines changed

demo/next.config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

helpers/hasCorrectNextConfig.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

helpers/verifyBuildTarget.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
const getNextConfig = require('./getNextConfig')
2+
const findUp = require('find-up')
3+
const { writeFile, unlink } = require('fs-extra')
4+
const path = require('path')
5+
26
// Checks if site has the correct next.config.js
37
const verifyBuildTarget = async ({ failBuild }) => {
48
const { target } = await getNextConfig(failBuild)
@@ -32,6 +36,16 @@ const verifyBuildTarget = async ({ failBuild }) => {
3236
// Clear memoized cache
3337
getNextConfig.clear()
3438

39+
// Creating a config file, because otherwise Next won't reload the config and pick up the new target
40+
41+
if (!(await findUp('next.config.js'))) {
42+
await writeFile(path.resolve('next.config.js'), `module.exports = {}`)
43+
}
44+
// Force the new config to be generated
45+
await getNextConfig(failBuild)
46+
47+
// Reset the value in case something else is looking for it
48+
process.env.NOW_BUILDER = false
3549
/* eslint-enable fp/no-delete, node/no-unpublished-require */
3650
}
3751

0 commit comments

Comments
 (0)