Repository: withastro/astro
File: packages/astro/src/assets/fonts/vite-plugin-fonts.ts (TypeScript)

Code before:
		const root = settings.config.root;
		const pathsToWarn = new Set<string>();

		for (const family of settings.config.experimental.fonts!) {
			families.push(
				await resolveFontFamily({
					family,
					root,
					resolveMod,
					generateNameWithHash: (_family) =>
						`${withoutQuotes(_family.name)}-${h64ToString(JSON.stringify(sortObjectByKey(_family)))}`,
					resolveLocalEntrypoint: (url) => {
						const resolvedPath = fileURLToPath(resolveEntrypoint(root, url));
						if (resolvedPath.startsWith(fileURLToPath(settings.config.publicDir))) {
							pathsToWarn.add(resolvedPath);
						}
						return resolvedPath;
					},
				}),
			);
		}

		for (const path of [...pathsToWarn]) {
			logger.warn(
				'assets',
				`The font file ${JSON.stringify(path)} used by a local family is located in \`config.publicDir\`. This will result in duplicated files in the output.`,
			);
		}

		await loadFonts({
			base: baseUrl,
			families,
			storage,
			hashToUrlMap,
			resolvedMap,
			hashString: h64ToString,
			generateFallbackFontFace,
			getMetricsForFamily: async (name, font) => {
				return await readMetrics(name, await cache(storage!, font.hash, () => fetchFont(font.url)));
			},
			log: (message) => logger.info('assets', message),
		});
	}

	return {
		name: 'astro:fonts',
		config(_, { command }) {
			isBuild = command === 'build';
		},
		async buildStart() {
			if (isBuild) {

Review comment (refactor):
This might be helpful if it suggests something people might want to *do*?

maybe something like:

> Found a local font file `${JSON.stringify(path)}` in the `public/` folder. To avoid duplicated files in the build output, move this file into `src/`.

Code after:
		const root = settings.config.root;
		const pathsToWarn = new Set<string>();

		for (const family of settings.config.experimental.fonts!) {
			families.push(
				await resolveFontFamily({
					family,
					root,
					resolveMod,
					generateNameWithHash: (_family) =>
						`${withoutQuotes(_family.name)}-${h64ToString(JSON.stringify(sortObjectByKey(_family)))}`,
					resolveLocalEntrypoint: (url) => {
						const resolvedPath = fileURLToPath(resolveEntrypoint(root, url));
						if (resolvedPath.startsWith(fileURLToPath(settings.config.publicDir))) {
							pathsToWarn.add(resolvedPath);
						}
						return resolvedPath;
					},
				}),
			);
		}

		for (const path of [...pathsToWarn]) {
			// TODO: remove when stabilizing
			logger.warn(
				'assets',
				`Found a local font file ${JSON.stringify(path)} in the \`public/\` folder. To avoid duplicated files in the build output, move this file into \`src/\``,
			);
		}

		await loadFonts({
			base: baseUrl,
			families,
			storage,
			hashToUrlMap,
			resolvedMap,
			hashString: h64ToString,
			generateFallbackFontFace,
			getMetricsForFamily: async (name, font) => {
				return await readMetrics(name, await cache(storage!, font.hash, () => fetchFont(font.url)));
			},
			log: (message) => logger.info('assets', message),
		});
	}

	return {
		name: 'astro:fonts',
		config(_, { command }) {
			isBuild = command === 'build';
		},
		async buildStart() {