full site update
This commit is contained in:
2
node_modules/astro/dist/vite-plugin-config-alias/index.d.ts
generated
vendored
2
node_modules/astro/dist/vite-plugin-config-alias/index.d.ts
generated
vendored
@@ -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;
|
||||
|
17
node_modules/astro/dist/vite-plugin-config-alias/index.js
generated
vendored
17
node_modules/astro/dist/vite-plugin-config-alias/index.js
generated
vendored
@@ -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({
|
||||
|
Reference in New Issue
Block a user