mirror of
https://github.com/fromchat-messenger/web.git
synced 2026-09-22 19:15:08 +03:00
Fix HMR
This commit is contained in:
@@ -62,6 +62,7 @@ function handleListItemClick(item: Element): void {
|
||||
function resetToFirstPanel(): void {
|
||||
const firstItem = settingsList.querySelector('mdui-list-item');
|
||||
const firstPanel = document.querySelector('.settings-panel');
|
||||
|
||||
if (firstItem && firstPanel) {
|
||||
settingsList.querySelectorAll('mdui-list-item').forEach(li => li.removeAttribute('active'));
|
||||
settingsPanels.forEach(panel => panel.classList.remove('active'));
|
||||
|
||||
+29
-4
@@ -1,9 +1,34 @@
|
||||
import { defineConfig, PluginOption } from 'vite';
|
||||
import { createHtmlPlugin } from 'vite-plugin-html';
|
||||
import autoprefixer from 'autoprefixer';
|
||||
import electron from 'vite-plugin-electron/simple';
|
||||
import { defineConfig, PluginOption } from "vite";
|
||||
import { createHtmlPlugin } from "vite-plugin-html";
|
||||
import autoprefixer from "autoprefixer";
|
||||
import electron from "vite-plugin-electron/simple";
|
||||
|
||||
function hmrAutoAcceptPlugin(): PluginOption {
|
||||
const injectionLine = "if(import.meta.hot){import.meta.hot.accept()}";
|
||||
const fileRegex = /\.(m?jsx?|tsx?)$/;
|
||||
|
||||
return {
|
||||
name: "hmr-auto-accept",
|
||||
apply: "serve",
|
||||
enforce: "post",
|
||||
transform(code, id) {
|
||||
if (!fileRegex.test(id)) return null;
|
||||
if (id.endsWith(".d.ts")) return null;
|
||||
if (id.includes("node_modules")) return null;
|
||||
if (id.startsWith("\0") || id.includes("virtual:") || id.includes("/@vite/")) return null;
|
||||
if (code.includes("import.meta.hot.accept()")) return null;
|
||||
|
||||
if (!code.endsWith("\n")) {
|
||||
code += "\n";
|
||||
}
|
||||
code += injectionLine;
|
||||
return { code: code, map: null };
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const plugins: PluginOption[] = [
|
||||
hmrAutoAcceptPlugin(),
|
||||
createHtmlPlugin({
|
||||
minify: {
|
||||
collapseWhitespace: true,
|
||||
|
||||
Reference in New Issue
Block a user