mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-15 20:54:59 +08:00
Add some additional HMR cleanup for dev
This commit is contained in:
parent
d8d064210d
commit
cc1a1e751b
@ -28,6 +28,19 @@ limitations under the License.
|
|||||||
* For more details, see webpack.config.js:184 (string-replace-loader)
|
* For more details, see webpack.config.js:184 (string-replace-loader)
|
||||||
*/
|
*/
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
"use theming";
|
("use theming");
|
||||||
|
/**
|
||||||
|
* Clean up old hot-module script injections as they hog up memory
|
||||||
|
* and anything other than the newest one is really not needed at all.
|
||||||
|
* We don't need to do it more frequently than every half a minute or so,
|
||||||
|
* but it's done to delay full page reload due to app slowness.
|
||||||
|
*/
|
||||||
|
setInterval(() => {
|
||||||
|
const elements = Array.from(document.querySelectorAll("script[src*=hot-update]"));
|
||||||
|
if (elements.length > 1) {
|
||||||
|
const oldInjects = elements.slice(0, elements.length - 1);
|
||||||
|
oldInjects.forEach(e => e.remove());
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user