astroScriptsPostPlugin() — astro Function Reference
Architecture documentation for the astroScriptsPostPlugin() function in page-ssr.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD b901ef5a_5915_506a_be8f_f3865faad853["astroScriptsPostPlugin()"] 290beb10_73e9_2e05_55db_2da6633b4de1["page-ssr.ts"] b901ef5a_5915_506a_be8f_f3865faad853 -->|defined in| 290beb10_73e9_2e05_55db_2da6633b4de1 style b901ef5a_5915_506a_be8f_f3865faad853 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/vite-plugin-scripts/page-ssr.ts lines 8–43
export default function astroScriptsPostPlugin({
settings,
}: {
settings: AstroSettings;
}): VitePlugin {
return {
name: 'astro:scripts:page-ssr',
enforce: 'post',
transform(this, code, id) {
if (!isAstroServerEnvironment(this.environment)) return;
const hasInjectedScript = settings.scripts.some((s) => s.stage === 'page-ssr');
if (!hasInjectedScript) return;
const filename = normalizePath(id);
let fileURL: URL;
try {
fileURL = new URL(`file://${filename}`);
} catch {
// If we can't construct a valid URL, exit early
return;
}
const fileIsPage = isPage(fileURL, settings);
if (!fileIsPage) return;
const s = new MagicString(code, { filename });
s.prepend(`import '${PAGE_SSR_SCRIPT_ID}';\n`);
return {
code: s.toString(),
map: s.generateMap({ hires: 'boundary' }),
};
},
};
}
Domain
Subdomains
Source
Frequently Asked Questions
What does astroScriptsPostPlugin() do?
astroScriptsPostPlugin() is a function in the astro codebase, defined in packages/astro/src/vite-plugin-scripts/page-ssr.ts.
Where is astroScriptsPostPlugin() defined?
astroScriptsPostPlugin() is defined in packages/astro/src/vite-plugin-scripts/page-ssr.ts at line 8.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free