fix(webpack): enable in memory caching when building for node in watch mode (#18348)

This commit is contained in:
Matt Lewis 2023-09-06 19:24:27 +01:00 committed by GitHub
parent ac85a16a59
commit f30174b677
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -191,6 +191,12 @@ export function withNx(pluginOptions?: WithNxOptions): NxWebpackPlugin {
process.env.NODE_ENV === 'production' process.env.NODE_ENV === 'production'
? (process.env.NODE_ENV as 'development' | 'production') ? (process.env.NODE_ENV as 'development' | 'production')
: ('none' as const), : ('none' as const),
// When target is Node, the Webpack mode will be set to 'none' which disables in memory caching and causes a full rebuild on every change.
// So to mitigate this we enable in memory caching when target is Node and in watch mode.
cache:
options.target === ('node' as const) && options.watch
? { type: 'memory' as const }
: undefined,
devtool: devtool:
options.sourceMap === 'hidden' options.sourceMap === 'hidden'
? 'hidden-source-map' ? 'hidden-source-map'