Skip to content

Commit

Permalink
fix: plugin for next 11.0.2 moved webpack-config (#17529)
Browse files Browse the repository at this point in the history
closes #17519, #17476
  • Loading branch information
Barthélémy Ledoux authored Aug 2, 2021
1 parent 6c8f3a2 commit 130c086
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion npm/react/plugins/next/findNextWebpackConfig.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
// @ts-check
/// <reference types="next" />
const debug = require('debug')('@cypress/react')
const loadConfig = require('next/dist/next-server/server/config').default
const getNextJsBaseWebpackConfig = require('next/dist/build/webpack-config').default

async function getNextWebpackConfig (config) {
let loadConfig

try {
loadConfig = require('next/dist/next-server/server/config').default
} catch (e) {
if (e.code === 'MODULE_NOT_FOUND') {
// Starting from 11.0.2-canary.23, the server config file
// is not in the next-server folder anymore.
// @ts-ignore
loadConfig = require('next/dist/server/config').default
}

throw e
}
const nextConfig = await loadConfig('development', config.projectRoot)
const nextWebpackConfig = await getNextJsBaseWebpackConfig(
config.projectRoot,
Expand Down

0 comments on commit 130c086

Please sign in to comment.