summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Martin Trapp <94928215+martrapp@users.noreply.github.com> 2023-12-06 16:20:08 +0100
committerGravatar GitHub <noreply@github.com> 2023-12-06 16:20:08 +0100
commitab0281aee419e58c6079ca393987fe1ff0541dd5 (patch)
tree30799ce5c50b25bc39099d2369a22020d6d4de3c
parent58d643bcd8e7ecbef5352d28054669a63b9cfa9e (diff)
downloadastro-ab0281aee419e58c6079ca393987fe1ff0541dd5.tar.gz
astro-ab0281aee419e58c6079ca393987fe1ff0541dd5.tar.zst
astro-ab0281aee419e58c6079ca393987fe1ff0541dd5.zip
Adds source file properties to HTML elements only if devToolbar is enabled (#9343)
-rw-r--r--.changeset/famous-bobcats-vanish.md5
-rw-r--r--packages/astro/src/core/compile/compile.ts8
-rw-r--r--packages/astro/src/vite-plugin-astro/index.ts2
3 files changed, 14 insertions, 1 deletions
diff --git a/.changeset/famous-bobcats-vanish.md b/.changeset/famous-bobcats-vanish.md
new file mode 100644
index 000000000..873cea592
--- /dev/null
+++ b/.changeset/famous-bobcats-vanish.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Adds source file properties to HTML elements only if devToolbar is enabled
diff --git a/packages/astro/src/core/compile/compile.ts b/packages/astro/src/core/compile/compile.ts
index c2f58fb9f..97625f021 100644
--- a/packages/astro/src/core/compile/compile.ts
+++ b/packages/astro/src/core/compile/compile.ts
@@ -10,10 +10,12 @@ import { AggregateError, CompilerError } from '../errors/errors.js';
import { AstroErrorData } from '../errors/index.js';
import { resolvePath } from '../util.js';
import { createStylePreprocessor } from './style.js';
+import type { AstroPreferences } from '../../preferences/index.js';
export interface CompileProps {
astroConfig: AstroConfig;
viteConfig: ResolvedConfig;
+ preferences: AstroPreferences;
filename: string;
source: string;
}
@@ -26,6 +28,7 @@ export interface CompileResult extends TransformResult {
export async function compile({
astroConfig,
viteConfig,
+ preferences,
filename,
source,
}: CompileProps): Promise<CompileResult> {
@@ -48,7 +51,10 @@ export async function compile({
resultScopedSlot: true,
transitionsAnimationURL: 'astro/components/viewtransitions.css',
annotateSourceFile:
- viteConfig.command === 'serve' && astroConfig.devToolbar && astroConfig.devToolbar.enabled,
+ viteConfig.command === 'serve' &&
+ astroConfig.devToolbar &&
+ astroConfig.devToolbar.enabled &&
+ (await preferences.get('devToolbar.enabled')),
preprocessStyle: createStylePreprocessor({
filename,
viteConfig,
diff --git a/packages/astro/src/vite-plugin-astro/index.ts b/packages/astro/src/vite-plugin-astro/index.ts
index 2aa6236ff..d02d78d6a 100644
--- a/packages/astro/src/vite-plugin-astro/index.ts
+++ b/packages/astro/src/vite-plugin-astro/index.ts
@@ -139,6 +139,7 @@ export default function astro({ settings, logger }: AstroPluginOptions): vite.Pl
const compileProps: CompileProps = {
astroConfig: config,
viteConfig: resolvedConfig,
+ preferences: settings.preferences,
filename: normalizePath(parsedId.filename),
source,
};
@@ -179,6 +180,7 @@ export default function astro({ settings, logger }: AstroPluginOptions): vite.Pl
cachedCompilation({
astroConfig: config,
viteConfig: resolvedConfig,
+ preferences: settings.preferences,
filename,
source,
});