Initial commit: New MoreminiMore website with fresh design
This commit is contained in:
7
node_modules/astro/dist/vite-plugin-hmr-reload/index.d.ts
generated
vendored
Normal file
7
node_modules/astro/dist/vite-plugin-hmr-reload/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { Plugin } from 'vite';
|
||||
/**
|
||||
* The very last Vite plugin to reload the browser if any SSR-only module are updated
|
||||
* which will require a full page reload. This mimics the behaviour of Vite 5 where
|
||||
* it used to unconditionally reload for us.
|
||||
*/
|
||||
export default function hmrReload(): Plugin;
|
||||
57
node_modules/astro/dist/vite-plugin-hmr-reload/index.js
generated
vendored
Normal file
57
node_modules/astro/dist/vite-plugin-hmr-reload/index.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
import { VIRTUAL_PAGE_RESOLVED_MODULE_ID } from "../vite-plugin-pages/const.js";
|
||||
import { getDevCssModuleNameFromPageVirtualModuleName } from "../vite-plugin-css/util.js";
|
||||
import { isAstroServerEnvironment } from "../environments.js";
|
||||
const STYLE_EXT_REGEX = /\.(?:css|scss|sass|less|styl|pcss)$/i;
|
||||
function isStyleModule(mod) {
|
||||
if (mod.file && STYLE_EXT_REGEX.test(mod.file)) return true;
|
||||
if (mod.id) {
|
||||
const idPath = mod.id.split("?")[0];
|
||||
if (STYLE_EXT_REGEX.test(idPath)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function hmrReload() {
|
||||
return {
|
||||
name: "astro:hmr-reload",
|
||||
enforce: "post",
|
||||
hotUpdate: {
|
||||
order: "post",
|
||||
handler({ modules, server, timestamp }) {
|
||||
if (!isAstroServerEnvironment(this.environment)) return;
|
||||
let hasSsrOnlyModules = false;
|
||||
let hasSkippedStyleModules = false;
|
||||
const invalidatedModules = /* @__PURE__ */ new Set();
|
||||
for (const mod of modules) {
|
||||
if (mod.id == null) continue;
|
||||
if (isStyleModule(mod)) {
|
||||
hasSkippedStyleModules = true;
|
||||
continue;
|
||||
}
|
||||
const clientModule = server.environments.client.moduleGraph.getModuleById(mod.id);
|
||||
if (clientModule != null) continue;
|
||||
this.environment.moduleGraph.invalidateModule(mod, invalidatedModules, timestamp, true);
|
||||
hasSsrOnlyModules = true;
|
||||
}
|
||||
for (const invalidatedModule of invalidatedModules) {
|
||||
if (invalidatedModule.id?.startsWith(VIRTUAL_PAGE_RESOLVED_MODULE_ID)) {
|
||||
const cssMod = this.environment.moduleGraph.getModuleById(
|
||||
getDevCssModuleNameFromPageVirtualModuleName(invalidatedModule.id)
|
||||
);
|
||||
if (!cssMod || cssMod.id == null) continue;
|
||||
this.environment.moduleGraph.invalidateModule(cssMod, void 0, timestamp, true);
|
||||
}
|
||||
}
|
||||
if (hasSsrOnlyModules) {
|
||||
server.ws.send({ type: "full-reload" });
|
||||
return [];
|
||||
}
|
||||
if (hasSkippedStyleModules) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
export {
|
||||
hmrReload as default
|
||||
};
|
||||
Reference in New Issue
Block a user