[ci] format
This commit is contained in:
parent
27ee8b97ae
commit
337318142a
2 changed files with 10 additions and 7 deletions
|
@ -2,7 +2,10 @@
|
|||
if (import.meta.hot) {
|
||||
import.meta.hot.on('vite:beforeUpdate', async (payload) => {
|
||||
for (const file of payload.updates) {
|
||||
if (file.acceptedPath.includes('svelte&type=style') || file.acceptedPath.includes('astro&type=style')) {
|
||||
if (
|
||||
file.acceptedPath.includes('svelte&type=style') ||
|
||||
file.acceptedPath.includes('astro&type=style')
|
||||
) {
|
||||
// This will only be called after the svelte component has hydrated in the browser.
|
||||
// At this point Vite is tracking component style updates, we need to remove
|
||||
// styles injected by Astro for the component in favor of Vite's internal HMR.
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { fileURLToPath } from 'node:url';
|
||||
import type { PluginContext as RollupPluginContext, ResolvedId } from 'rollup';
|
||||
import type { HmrContext, ModuleNode, ViteDevServer } from 'vite';
|
||||
import type { AstroConfig } from '../@types/astro';
|
||||
import type { LogOptions } from '../core/logger/core.js';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { info } from '../core/logger/core.js';
|
||||
import * as msg from '../core/messages.js';
|
||||
import { invalidateCompilation, isCached } from './compile.js';
|
||||
|
@ -50,15 +50,15 @@ export async function trackCSSDependencies(
|
|||
}
|
||||
}
|
||||
|
||||
const PKG_PREFIX = new URL('../../', import.meta.url)
|
||||
const isPkgFile = (id: string|null) => {
|
||||
return id?.startsWith(fileURLToPath(PKG_PREFIX)) || id?.startsWith(PKG_PREFIX.pathname)
|
||||
}
|
||||
const PKG_PREFIX = new URL('../../', import.meta.url);
|
||||
const isPkgFile = (id: string | null) => {
|
||||
return id?.startsWith(fileURLToPath(PKG_PREFIX)) || id?.startsWith(PKG_PREFIX.pathname);
|
||||
};
|
||||
|
||||
export async function handleHotUpdate(ctx: HmrContext, config: AstroConfig, logging: LogOptions) {
|
||||
// Invalidate the compilation cache so it recompiles
|
||||
invalidateCompilation(config, ctx.file);
|
||||
|
||||
|
||||
// Skip monorepo files to avoid console spam
|
||||
if (isPkgFile(ctx.file)) {
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue