Skip to content

Commit ab0281a

Browse files
authoredDec 6, 2023
Adds source file properties to HTML elements only if devToolbar is enabled (#9343)
1 parent 58d643b commit ab0281a

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed
 

‎.changeset/famous-bobcats-vanish.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Adds source file properties to HTML elements only if devToolbar is enabled

‎packages/astro/src/core/compile/compile.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import { AggregateError, CompilerError } from '../errors/errors.js';
1010
import { AstroErrorData } from '../errors/index.js';
1111
import { resolvePath } from '../util.js';
1212
import { createStylePreprocessor } from './style.js';
13+
import type { AstroPreferences } from '../../preferences/index.js';
1314

1415
export interface CompileProps {
1516
astroConfig: AstroConfig;
1617
viteConfig: ResolvedConfig;
18+
preferences: AstroPreferences;
1719
filename: string;
1820
source: string;
1921
}
@@ -26,6 +28,7 @@ export interface CompileResult extends TransformResult {
2628
export async function compile({
2729
astroConfig,
2830
viteConfig,
31+
preferences,
2932
filename,
3033
source,
3134
}: CompileProps): Promise<CompileResult> {
@@ -48,7 +51,10 @@ export async function compile({
4851
resultScopedSlot: true,
4952
transitionsAnimationURL: 'astro/components/viewtransitions.css',
5053
annotateSourceFile:
51-
viteConfig.command === 'serve' && astroConfig.devToolbar && astroConfig.devToolbar.enabled,
54+
viteConfig.command === 'serve' &&
55+
astroConfig.devToolbar &&
56+
astroConfig.devToolbar.enabled &&
57+
(await preferences.get('devToolbar.enabled')),
5258
preprocessStyle: createStylePreprocessor({
5359
filename,
5460
viteConfig,

‎packages/astro/src/vite-plugin-astro/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export default function astro({ settings, logger }: AstroPluginOptions): vite.Pl
139139
const compileProps: CompileProps = {
140140
astroConfig: config,
141141
viteConfig: resolvedConfig,
142+
preferences: settings.preferences,
142143
filename: normalizePath(parsedId.filename),
143144
source,
144145
};
@@ -179,6 +180,7 @@ export default function astro({ settings, logger }: AstroPluginOptions): vite.Pl
179180
cachedCompilation({
180181
astroConfig: config,
181182
viteConfig: resolvedConfig,
183+
preferences: settings.preferences,
182184
filename,
183185
source,
184186
});

0 commit comments

Comments
 (0)
Please sign in to comment.