Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions tools/postbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,7 @@ readDir(path.join(__dirname, rootDirectiory))
});
})
.then(() => {
// Copy index.html → app/index.html so static hosts (Amplify, S3, Nginx)
// can route /app/* to the CSR Angular shell.
// With SSR/prerender disabled the build outputs index.html directly (no index.csr.html).
const distIndexPath = path.join(__dirname, rootDirectiory, 'index.html');
const appShellDir = path.join(__dirname, rootDirectiory, 'app');
const appShellPath = path.join(appShellDir, 'index.html');

if (fs.existsSync(distIndexPath)) {
if (!fs.existsSync(appShellDir)) {
fs.mkdirSync(appShellDir, { recursive: true });
}

let appShellHtml = fs.readFileSync(distIndexPath, 'utf8');

// Force base href to "/" so JS chunks load from the root, not from /app/
if (!appShellHtml.includes('<base href="/">')) {
appShellHtml = appShellHtml.replace(/<base\s+href="[^"]*"\s*\/?>/i, '<base href="/" />');
}

fs.writeFileSync(appShellPath, appShellHtml);
console.log(`Copied index.html → app/index.html (base href enforced)`);
} else {
console.log('index.html not found, skipping app/index.html copy');
}
console.log('Post-build tasks complete');
})
.catch((err) => {
console.log('Error with post build:', err);
Expand Down
Loading