0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-03-24 23:21:57 -05:00

Adds source file properties to HTML elements only if devToolbar is enabled ()

This commit is contained in:
Martin Trapp 2023-12-06 16:20:08 +01:00 committed by GitHub
parent 58d643bcd8
commit ab0281aee4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions
.changeset
packages/astro/src
core/compile
vite-plugin-astro

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Adds source file properties to HTML elements only if devToolbar is enabled

View file

@ -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,

View file

@ -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,
});