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 (#9343)
This commit is contained in:
parent
58d643bcd8
commit
ab0281aee4
3 changed files with 14 additions and 1 deletions
5
.changeset/famous-bobcats-vanish.md
Normal file
5
.changeset/famous-bobcats-vanish.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Adds source file properties to HTML elements only if devToolbar is enabled
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue