You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(rspeedy/core): add dev.hmr and dev.liveReload (#458)
<!--
Thank you for submitting a pull request!
We appreciate the time and effort you have invested in making these
changes. Please ensure that you provide enough information to allow
others to review your pull request.
Upon submission, your pull request will be automatically assigned with
reviewers.
If you want to learn more about contributing to this project, please
visit:
https://github.com/lynx-family/lynx-stack/blob/main/CONTRIBUTING.md.
-->
## Summary
<!-- Can you explain the reasoning behind implementing this change? What
problem or issue does this pull request resolve? -->
fix: #298
<!-- It would be helpful if you could provide any relevant context, such
as GitHub issues or related discussions. -->
## Checklist
<!--- Check and mark with an "x" -->
- [x] Tests updated (or not required).
- [x] Documentation updated (or not required).
---------
Signed-off-by: Qingyu Wang <[email protected]>
Co-authored-by: Yradex <[email protected]>
Copy file name to clipboardExpand all lines: packages/rspeedy/core/src/config/dev/index.ts
+82Lines changed: 82 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -75,6 +75,88 @@ export interface Dev {
75
75
*/
76
76
client?: Client|undefined
77
77
78
+
/**
79
+
* Whether to enable Hot Module Replacement (HMR).
80
+
*
81
+
* @remarks
82
+
*
83
+
* Defaults to `true`.
84
+
*
85
+
* By default, Rspeedy uses HMR as the preferred method to update modules. If HMR is disabled or cannot be used in certain scenarios, it will automatically fallback to {@link Dev.liveReload}.
86
+
*
87
+
* To completely disable both HMR and live reload, set both `dev.hmr` and `dev.liveReload` to `false`. Then, no WebSocket requests will be made to the dev server on the page, and the page will not automatically refresh when file changes.
88
+
*
89
+
* @example
90
+
*
91
+
* Disable HMR:
92
+
*
93
+
* ```js
94
+
* import { defineConfig } from '@lynx-js/rspeedy'
95
+
*
96
+
* export default defineConfig({
97
+
* dev: {
98
+
* hmr: false,
99
+
* },
100
+
* })
101
+
* ```
102
+
*
103
+
* @example
104
+
*
105
+
* Disable both HMR and live reload:
106
+
*
107
+
* ```js
108
+
* import { defineConfig } from '@lynx-js/rspeedy'
109
+
*
110
+
* export default defineConfig({
111
+
* dev: {
112
+
* hmr: false,
113
+
* liveReload: false,
114
+
* },
115
+
* })
116
+
* ```
117
+
*/
118
+
hmr?: boolean|undefined
119
+
120
+
/**
121
+
* Whether to enable live reload functionality.
122
+
*
123
+
* Defaults to `true`.
124
+
*
125
+
* Live reload is used as a fallback when {@link Dev.hmr} is disabled or cannot be used in certain scenarios. When enabled, the page will automatically refresh when source files are changed.
126
+
*
127
+
* To completely disable both HMR and live reload, set both `dev.hmr` and `dev.liveReload` to `false`. Then, no WebSocket requests will be made to the dev server on the page, and the page will not automatically refresh when file changes.
128
+
*
129
+
* @example
130
+
*
131
+
* Disable live reload:
132
+
*
133
+
* ```js
134
+
* import { defineConfig } from '@lynx-js/rspeedy'
135
+
*
136
+
* export default defineConfig({
137
+
* dev: {
138
+
* liveReload: false,
139
+
* },
140
+
* })
141
+
* ```
142
+
*
143
+
* @example
144
+
*
145
+
* Disable both HMR and live reload:
146
+
*
147
+
* ```js
148
+
* import { defineConfig } from '@lynx-js/rspeedy'
149
+
*
150
+
* export default defineConfig({
151
+
* dev: {
152
+
* hmr: false,
153
+
* liveReload: false,
154
+
* },
155
+
* })
156
+
* ```
157
+
*/
158
+
liveReload?: boolean|undefined
159
+
78
160
/**
79
161
* Watch specified files and directories for changes. When a file change is detected, it can trigger a page reload or restart the dev server.
0 commit comments