From 0968cb1a373b1101a649035d2ea2210d3d6412dc Mon Sep 17 00:00:00 2001 From: Arsh <69170106+lilnasy@users.noreply.github.com> Date: Mon, 4 Dec 2023 19:59:35 +0000 Subject: [PATCH] fix(astro compiler): check vite command to decide on "annotateSourceFile" (#9275) * prevent annotations in build * add changeset * Apply suggestions from code review Co-authored-by: Bjorn Lu --------- Co-authored-by: Bjorn Lu --- .changeset/chatty-poems-doubt.md | 5 +++++ packages/astro/src/core/compile/compile.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/chatty-poems-doubt.md diff --git a/.changeset/chatty-poems-doubt.md b/.changeset/chatty-poems-doubt.md new file mode 100644 index 000000000000..32bc05c9d5ea --- /dev/null +++ b/.changeset/chatty-poems-doubt.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes an issue where html annotations relevant only to the dev server were included in the production build. diff --git a/packages/astro/src/core/compile/compile.ts b/packages/astro/src/core/compile/compile.ts index 8a187e652f85..2877d6a3ebc3 100644 --- a/packages/astro/src/core/compile/compile.ts +++ b/packages/astro/src/core/compile/compile.ts @@ -48,7 +48,7 @@ export async function compile({ resultScopedSlot: true, transitionsAnimationURL: 'astro/components/viewtransitions.css', annotateSourceFile: - !viteConfig.isProduction && astroConfig.devToolbar && astroConfig.devToolbar.enabled, + viteConfig.command === "serve" && astroConfig.devToolbar && astroConfig.devToolbar.enabled, preprocessStyle: createStylePreprocessor({ filename, viteConfig,