Skip to content

Commit

Permalink
change next webpack cache path
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachJW34 committed Jul 19, 2022
1 parent 6c56467 commit 56f5d69
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions npm/webpack-dev-server/src/helpers/nextHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export async function nextHandler (devServerConfig: WebpackDevServerConfig): Pro
checkSWC(webpackConfig, devServerConfig.cypressConfig)
watchEntryPoint(webpackConfig)
allowGlobalStylesImports(webpackConfig)
changeNextCachePath(webpackConfig)

return { frameworkConfig: webpackConfig, sourceWebpackModulesResult: sourceNextWebpackDeps(devServerConfig) }
}
Expand Down Expand Up @@ -283,3 +284,15 @@ function allowGlobalStylesImports (webpackConfig: Configuration) {
}
}
}

// Our modifications of the Next webpack config can corrupt the cache used for local development.
// We separate the cache used for CT from the normal cache (".next/cache/webpack" -> ".next/cache/cypress-webpack") so they don't interfere with each other
function changeNextCachePath (webpackConfig: Configuration) {
if (webpackConfig.cache && typeof webpackConfig.cache === 'object' && ('cacheDirectory' in webpackConfig.cache) && webpackConfig.cache.cacheDirectory) {
const { cacheDirectory } = webpackConfig.cache

webpackConfig.cache.cacheDirectory = cacheDirectory.replace(/webpack$/, 'cypress-webpack')

debug('Changing Next cache path from %s to %s', cacheDirectory, webpackConfig.cache.cacheDirectory)
}
}

0 comments on commit 56f5d69

Please sign in to comment.