Skip to content

Commit

Permalink
Adds source file properties to HTML elements only if devToolbar is en…
Browse files Browse the repository at this point in the history
…abled
  • Loading branch information
martrapp committed Dec 6, 2023
1 parent 339be4d commit 10802dd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/famous-bobcats-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Adds source file properties to HTML elements only if devToolbar is enabled
8 changes: 7 additions & 1 deletion packages/astro/src/core/compile/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -26,6 +28,7 @@ export interface CompileResult extends TransformResult {
export async function compile({
astroConfig,
viteConfig,
preferences,
filename,
source,
}: CompileProps): Promise<CompileResult> {
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions packages/astro/src/vite-plugin-astro/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -179,6 +180,7 @@ export default function astro({ settings, logger }: AstroPluginOptions): vite.Pl
cachedCompilation({
astroConfig: config,
viteConfig: resolvedConfig,
preferences: settings.preferences,
filename,
source,
});
Expand Down

0 comments on commit 10802dd

Please sign in to comment.