netlifyIntegration() — astro Function Reference
Architecture documentation for the netlifyIntegration() function in index.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 0524ca9e_035f_83b7_32b4_4d658f83f56c["netlifyIntegration()"] 01c2fa75_d554_caf7_1c43_205032b5e695["index.ts"] 0524ca9e_035f_83b7_32b4_4d658f83f56c -->|defined in| 01c2fa75_d554_caf7_1c43_205032b5e695 242ad5a4_662b_3ad6_2c84_c29d228d0286["remoteImagesFromAstroConfig()"] 0524ca9e_035f_83b7_32b4_4d658f83f56c -->|calls| 242ad5a4_662b_3ad6_2c84_c29d228d0286 f25b5d53_375e_edea_840f_c6ce7d1640f3["writeNetlifyFrameworkConfig()"] 0524ca9e_035f_83b7_32b4_4d658f83f56c -->|calls| f25b5d53_375e_edea_840f_c6ce7d1640f3 2fc85e65_a682_3fc0_37e4_1db04ca4c873["writeSkewProtectionConfig()"] 0524ca9e_035f_83b7_32b4_4d658f83f56c -->|calls| 2fc85e65_a682_3fc0_37e4_1db04ca4c873 style 0524ca9e_035f_83b7_32b4_4d658f83f56c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/integrations/netlify/src/index.ts lines 281–771
export default function netlifyIntegration(
integrationConfig?: NetlifyIntegrationConfig,
): AstroIntegration {
const isRunningInNetlify = Boolean(
process.env.NETLIFY || process.env.NETLIFY_LOCAL || process.env.NETLIFY_DEV,
);
let _config: AstroConfig;
let outDir: URL;
let rootDir: URL;
let astroMiddlewareEntryPoint: URL | undefined = undefined;
let staticHeadersMap: RouteToHeaders | undefined = undefined;
// Extra files to be merged with `includeFiles` during build
const extraFilesToInclude: URL[] = [];
// Secret used to verify that the caller is the astro-generated edge middleware and not a third-party
const middlewareSecret = randomUUID();
let finalBuildOutput: HookParameters<'astro:config:done'>['buildOutput'];
const TRACE_CACHE = {};
const ssrBuildDir = () => new URL('./.netlify/build/', rootDir);
const ssrOutputDir = () => new URL('./.netlify/v1/functions/ssr/', rootDir);
const middlewareOutputDir = () => new URL('.netlify/v1/edge-functions/middleware/', rootDir);
const cleanFunctions = async () =>
await Promise.all([
emptyDir(middlewareOutputDir()),
emptyDir(ssrOutputDir()),
emptyDir(ssrBuildDir()),
]);
async function writeRedirects(
routes: IntegrationResolvedRoute[],
dir: URL,
buildOutput: HookParameters<'astro:config:done'>['buildOutput'],
assets: HookParameters<'astro:build:done'>['assets'],
) {
// all other routes are handled by SSR
const staticRedirects = routes.filter(
(route) => route.type === 'redirect' && (route.redirect || route.redirectRoute),
);
// this is needed to support redirects to dynamic routes
// on static. not sure why this is needed, but it works.
for (const { pattern, redirectRoute } of staticRedirects) {
const distURL = assets.get(pattern);
if (!distURL && redirectRoute) {
const redirectDistURL = assets.get(redirectRoute.pattern);
if (redirectDistURL) {
assets.set(pattern, redirectDistURL);
}
}
}
const fallback = finalBuildOutput === 'static' ? '/.netlify/static' : '/.netlify/functions/ssr';
const redirects = createRedirectsFromAstroRoutes({
config: _config,
dir,
routeToDynamicTargetMap: new Map(staticRedirects.map((route) => [route, fallback])),
buildOutput,
assets,
});
if (!redirects.empty()) {
await appendFile(new URL('_redirects', outDir), `\n${printAsRedirects(redirects)}\n`);
}
}
async function getFilesByGlob(
include: Array<string> = [],
exclude: Array<string> = [],
): Promise<Array<URL>> {
const files = await glob(include, {
cwd: fileURLToPath(rootDir),
absolute: true,
ignore: exclude,
expandDirectories: false,
});
return files.map((file) => pathToFileURL(file));
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does netlifyIntegration() do?
netlifyIntegration() is a function in the astro codebase, defined in packages/integrations/netlify/src/index.ts.
Where is netlifyIntegration() defined?
netlifyIntegration() is defined in packages/integrations/netlify/src/index.ts at line 281.
What does netlifyIntegration() call?
netlifyIntegration() calls 3 function(s): remoteImagesFromAstroConfig, writeNetlifyFrameworkConfig, writeSkewProtectionConfig.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free