Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tender-wasps-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Improves syncing
4 changes: 2 additions & 2 deletions packages/astro/src/assets/fonts/vite-plugin-fonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ interface Options {
}

export function fontsPlugin({ settings, sync, logger }: Options): Plugin {
if (sync || !settings.config.experimental.fonts) {
if (!settings.config.experimental.fonts) {
// This is required because the virtual module may be imported as
// a side effect
// TODO: remove once fonts are stabilized
Expand Down Expand Up @@ -319,7 +319,7 @@ export function fontsPlugin({ settings, sync, logger }: Options): Plugin {
}
},
async buildEnd() {
if (settings.config.experimental.fonts!.length === 0) {
if (sync || settings.config.experimental.fonts!.length === 0) {
cleanup();
return;
}
Expand Down
21 changes: 20 additions & 1 deletion packages/astro/src/core/sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,26 @@ async function syncContentCollections(
ssr: { external: [] },
logLevel: 'silent',
},
{ settings, logger, mode, command: 'build', fs, sync: true, routesList, manifest },
{
// Prevent mutation of specific properties by vite plugins during sync
settings: {
...settings,
// Prevent mutation by vite plugins during sync
buildOutput: undefined,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we can achieve this using TypeScript? I know it has the type Readonly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so in this context. Because we still need it to be reassigned at some point, so we can't just update AstroSettings['buildOutput']

// Sync causes font resources and style hashes to be duplicated
injectedCsp: {
fontResources: new Set(),
styleHashes: [],
},
},
logger,
mode,
command: 'build',
fs,
sync: true,
routesList,
manifest,
},
),
);

Expand Down
Loading