Skip to content

Commit

Permalink
fix(webpack): enable in memory caching when building for node in watc…
Browse files Browse the repository at this point in the history
…h mode (#18348)

(cherry picked from commit f30174b)
  • Loading branch information
mattlewis92 authored and FrozenPandaz committed Sep 7, 2023
1 parent 62f526a commit 1f10398
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/webpack/src/utils/with-nx.ts
Expand Up @@ -191,6 +191,12 @@ export function withNx(pluginOptions?: WithNxOptions): NxWebpackPlugin {
process.env.NODE_ENV === 'production'
? (process.env.NODE_ENV as 'development' | 'production')
: ('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:
options.sourceMap === 'hidden'
? 'hidden-source-map'
Expand Down

0 comments on commit 1f10398

Please sign in to comment.