
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
astro-manifestor
Advanced tools
Extracts JS, CSS, and Astro islands from built HTML into manifest.json
🇷🇺 Документация на русском: README.ru.md
astro-manifestor is a CLI tool that generates a manifest.json
and extracts inline <script>
blocks into external files — for example, after building Astro in static
mode or using another SSG.
dist
.js
filesmanifest.json
with per-page dependency mappingAstro and similar SSGs produce HTML that includes:
When integrating such static output into server-side frameworks like Laravel, Bitrix, or Symfony, where HTML is composed via Blade/Twig/PHP, you often need to know exactly which assets each page depends on.
astro-manifestor helps:
.js
files (for CSP and caching)npx astro-manifestor \
--inputDir ./dist \
--manifestOutFile ./dist/assets/manifest.json \
--inlineScriptsOutDir ./dist/assets/js \
--inlineScriptsPublicPath /assets/js \
--inlineScriptPrefix inline-script- \
--verbose
Or from a package.json
script:
{
"scripts": {
"build:manifest": "npx astro-manifestor"
}
}
npm install --save-dev astro-manifestor
Option | Description |
---|---|
--inputDir | Directory with HTML files (e.g. dist/ ) |
--manifestOutFile | Output path for manifest.json |
--inlineScriptsOutDir | Where extracted inline scripts are saved |
--inlineScriptsPublicPath | Public path used in manifest |
--inlineScriptPrefix | Prefix for inline script filenames (e.g. inline-script- ) |
--verbose | (optional) Print detailed progress info |
Use astro-manifestor.config.js
or .ts
in your project root:
export default {
inputDir: 'dist',
manifestOutFile: 'dist/assets/manifest.json',
inlineScriptsOutDir: 'dist/assets/js',
inlineScriptsPublicPath: '/assets/js',
inlineScriptPrefix: 'inline-script-',
verbose: true,
prettierOptions: {
tabWidth: 4,
printWidth: 80,
htmlWhitespaceSensitivity: 'ignore',
},
}
export default {
transformManifest: (manifestMap) => {
for (const key in manifestMap) {
const entry = manifestMap[key];
for (const islandName in entry.islands) {
const island = entry.islands[islandName];
if (island.componentUrl) {
island.componentUrl = 'https://example.com' + island.componentUrl;
}
}
}
return manifestMap;
},
};
Useful when:
.ts
or .js
config files are supported and loaded automatically.
{
"dist/index.html": {
"js": [
"/assets/js/inline-script-2mu117.js",
"/assets/js/ModuleOne.astro_astro_type_script_index_0_lang-CTXcsgZ5.js",
"/assets/js/Layout.astro_astro_type_script_index_0_lang-DvaTEbLM.js"
],
"css": [
"/assets/css/index-mR53M-XZ.css",
"/assets/css/chunk-Bj5H1zmF.css"
],
"islands": {
"Hello": {
"uid": "Z2f1Nmm",
"componentUrl": "https://example.com/assets/js/Hello-CGVomTcg.js",
"componentExport": "default",
"rendererUrl": "/assets/js/client-dDWe5wvR.js",
"client": "only",
"props": "{}",
"ssr": ""
}
}
},
"dist/about/index.html": {
"js": [],
"css": [],
"islands": {}
}
}
<body>
<script type="module" src="/assets/js/component-A.js"></script>
<h1>Hello</h1>
<script>(() => {
console.log('inline logic');
})();</script>
<script type="module" src="/assets/js/component-B.js"></script>
</body>
<body>
<h1>Hello</h1>
<script src="/assets/js/inline-script-abc123.js"></script>
<script type="module" src="/assets/js/component-A.js"></script>
<script type="module" src="/assets/js/component-B.js"></script>
</body>
✅ What happens:
<script>
tags are moved to the end of <body>
.js
filesFAQs
Extracts JS, CSS, and Astro islands from built HTML into manifest.json
We found that astro-manifestor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.