Skip to content

Commit e74300a

Browse files
committedJan 9, 2025
fix(@angular/build): use component updates for component style HMR
The newly stable template HMR support has also been improved to support hot replacement of component stylesheets. While this is not as fast during a rebuild as external stylesheet based HMR, it does currently avoid some edge cases with the current implementation. Once these cases are resolved, the default may be reverted to the previous setup. If the previous behavior is preferred, the `NG_HMR_CSTYLES=1` environment variable can be used. (cherry picked from commit ba51e72)
1 parent 8aa1ce6 commit e74300a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed
 

‎packages/angular/build/src/builders/dev-server/vite-server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export async function* serveWithVite(
138138
process.setSourceMapsEnabled(true);
139139
}
140140

141-
// Enable to support link-based component style hot reloading (`NG_HMR_CSTYLES=0` can be used to disable selectively)
141+
// Enable to support link-based component style hot reloading (`NG_HMR_CSTYLES=1` can be used to enable)
142142
browserOptions.externalRuntimeStyles =
143143
serverOptions.liveReload && serverOptions.hmr && useComponentStyleHmr;
144144

‎packages/angular/build/src/utils/environment-options.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const shouldOptimizeChunks =
103103

104104
const hmrComponentStylesVariable = process.env['NG_HMR_CSTYLES'];
105105
export const useComponentStyleHmr =
106-
!isPresent(hmrComponentStylesVariable) || !isDisabled(hmrComponentStylesVariable);
106+
isPresent(hmrComponentStylesVariable) && isEnabled(hmrComponentStylesVariable);
107107

108108
const hmrComponentTemplateVariable = process.env['NG_HMR_TEMPLATES'];
109109
export const useComponentTemplateHmr =

0 commit comments

Comments
 (0)