full site update

This commit is contained in:
2025-07-24 18:46:24 +02:00
parent bfe2b90d8d
commit 37a6e0ab31
6912 changed files with 540482 additions and 361712 deletions

View File

@@ -1,5 +1,5 @@
import { type Plugin as VitePlugin } from 'vite';
import type { AstroSettings } from '../@types/astro.js';
import type { AstroSettings } from '../types/astro.js';
/** Returns a Vite plugin used to alias paths from tsconfig.json and jsconfig.json. */
export default function configAliasVitePlugin({ settings, }: {
settings: AstroSettings;

View File

@@ -4,8 +4,9 @@ const getConfigAlias = (settings) => {
const { tsConfig, tsConfigPath } = settings;
if (!tsConfig || !tsConfigPath || !tsConfig.compilerOptions) return null;
const { baseUrl, paths } = tsConfig.compilerOptions;
if (!baseUrl) return null;
const resolvedBaseUrl = path.resolve(path.dirname(tsConfigPath), baseUrl);
const effectiveBaseUrl = baseUrl ?? (paths ? "." : void 0);
if (!effectiveBaseUrl) return null;
const resolvedBaseUrl = path.resolve(path.dirname(tsConfigPath), effectiveBaseUrl);
const aliases = [];
if (paths) {
for (const [alias, values] of Object.entries(paths)) {
@@ -14,17 +15,19 @@ const getConfigAlias = (settings) => {
(segment) => segment === "*" ? "(.+)" : segment.replace(/[\\^$*+?.()|[\]{}]/, "\\$&")
).join("")}$`
);
let matchId = 0;
for (const value of values) {
let matchId = 0;
const replacement = [...normalizePath(path.resolve(resolvedBaseUrl, value))].map((segment) => segment === "*" ? `$${++matchId}` : segment === "$" ? "$$" : segment).join("");
aliases.push({ find, replacement });
}
}
}
aliases.push({
find: /^(?!\.*\/|\.*$|\w:)(.+)$/,
replacement: `${[...normalizePath(resolvedBaseUrl)].map((segment) => segment === "$" ? "$$" : segment).join("")}/$1`
});
if (baseUrl) {
aliases.push({
find: /^(?!\.*\/|\.*$|\w:)(.+)$/,
replacement: `${[...normalizePath(resolvedBaseUrl)].map((segment) => segment === "$" ? "$$" : segment).join("")}/$1`
});
}
return aliases;
};
function configAliasVitePlugin({