Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(@angular/build): enable component stylesheet hot replacement by default #28646

Merged
merged 2 commits into from
Oct 16, 2024

Conversation

clydin
Copy link
Member

@clydin clydin commented Oct 16, 2024

When using the application builder (default for new projects) with the development server, component style only changes will now automatically replace the styles within the running application without a full reload of the page. No application code changes are necessary and both file-based (styleUrl/styleUrls) and inline (styles) component styles are supported. Within a component template, <style> elements and <link rel="stylesheet"> elements with relative href attributes are also supported.

If any issues are encountered or it is preferred to not hot replace component styles, the NG_HMR_CSTYLES=0 environment variable can be used to disable the feature. Setting the liveReload option to false will also disable all updates.

@clydin clydin added the target: major This PR is targeted for the next major release label Oct 16, 2024
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: @angular/build labels Oct 16, 2024
@clydin clydin force-pushed the application/component-style-hmr branch from 7cf65cf to b5eb852 Compare October 16, 2024 15:49
@clydin clydin marked this pull request as ready for review October 16, 2024 16:01
@clydin clydin force-pushed the application/component-style-hmr branch from b5eb852 to 656f5b8 Compare October 16, 2024 16:33
Copy link
Collaborator

@dgp1130 dgp1130 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just some minor readability suggestions. Up to you if they're worth changing.

// TODO: Enable by default once full support across CLI and FW is integrated
browserOptions.externalRuntimeStyles = useComponentStyleHmr;
// Enable to support component style hot reloading (`NG_HMR_CSTYLES=0` can be used to disable)
browserOptions.externalRuntimeStyles = !!serverOptions.liveReload && useComponentStyleHmr;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider: Prefer Boolean(...) over !! to be more clear about your intent.

@clydin clydin force-pushed the application/component-style-hmr branch from 656f5b8 to 3ea7e12 Compare October 16, 2024 16:44
…default

When using the `application` builder (default for new projects) with the
development server, component style only changes will now automatically
replace the styles within the running application without a full reload
of the page. No application code changes are necessary and both file-based
(`styleUrl`/`styleUrls`) and inline (`styles`) component styles are supported.
Within a component template, `<style>` elements and `<link rel="stylesheet">`
elements with relative `href` attributes are also supported.

If any issues are encountered or it is preferred to not hot replace component
styles, the `NG_HMR_CSTYLES=0` environment variable can be used to disable
the feature. Setting the `liveReload` option to false will also disable all
updates.
@clydin clydin force-pushed the application/component-style-hmr branch from 3ea7e12 to 09e915f Compare October 16, 2024 17:19
@clydin clydin added the action: merge The PR is ready for merge by the caretaker label Oct 16, 2024
@clydin clydin removed the request for review from alan-agius4 October 16, 2024 17:43
@clydin clydin merged commit bf1845b into angular:main Oct 16, 2024
31 checks passed
@clydin clydin deleted the application/component-style-hmr branch October 16, 2024 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: @angular/build detected: feature PR contains a feature commit target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants