Skip to content

Commit 130c086

Browse files
author
Barthélémy Ledoux
authored
fix: plugin for next 11.0.2 moved webpack-config (#17529)
closes #17519, #17476
1 parent 6c8f3a2 commit 130c086

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

npm/react/plugins/next/findNextWebpackConfig.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
// @ts-check
22
/// <reference types="next" />
33
const debug = require('debug')('@cypress/react')
4-
const loadConfig = require('next/dist/next-server/server/config').default
54
const getNextJsBaseWebpackConfig = require('next/dist/build/webpack-config').default
65

76
async function getNextWebpackConfig (config) {
7+
let loadConfig
8+
9+
try {
10+
loadConfig = require('next/dist/next-server/server/config').default
11+
} catch (e) {
12+
if (e.code === 'MODULE_NOT_FOUND') {
13+
// Starting from 11.0.2-canary.23, the server config file
14+
// is not in the next-server folder anymore.
15+
// @ts-ignore
16+
loadConfig = require('next/dist/server/config').default
17+
}
18+
19+
throw e
20+
}
821
const nextConfig = await loadConfig('development', config.projectRoot)
922
const nextWebpackConfig = await getNextJsBaseWebpackConfig(
1023
config.projectRoot,

0 commit comments

Comments
 (0)