Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent getCollection from breaking in vitest #10846

Merged
merged 6 commits into from
Apr 23, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Oops
  • Loading branch information
matthewp committed Apr 22, 2024
commit 87b9c99c7f9c9620459af698e9eb83be5f5c7814
6 changes: 3 additions & 3 deletions packages/astro/src/assets/vite-plugin-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default function assets({
mode,
}: AstroPluginOptions & { mode: string }): vite.Plugin[] {
let resolvedConfig: vite.ResolvedConfig;
let viteCommand: vite.ConfigEnv['command'];
let shouldEmitFile = false;

globalThis.astroAsset = {
referencedImages: new Set(),
Expand Down Expand Up @@ -196,7 +196,7 @@ export default function assets({
name: 'astro:assets:esm',
enforce: 'pre',
config(_, env) {
env.command;
shouldEmitFile = env.command === 'build';
},
configResolved(viteConfig) {
resolvedConfig = viteConfig;
Expand All @@ -218,7 +218,7 @@ export default function assets({
return;
}

const emitFile = viteCommand === 'build' ? this.emitFile : undefined;
const emitFile = shouldEmitFile ? this.emitFile : undefined;
const imageMetadata = await emitESMImage(id, this.meta.watchMode, emitFile);

if (!imageMetadata) {
Expand Down
Loading