Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 0 additions & 5 deletions apps/36-blocks/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
"outputPath": "dist/apps/36-blocks",
"index": "apps/36-blocks/src/index.html",
"browser": "apps/36-blocks/src/main.ts",
"server": "apps/36-blocks/src/main.server.ts",
"prerender": true,
"ssr": {
"entry": "apps/36-blocks/src/server.ts"
},
"polyfills": ["zone.js"],
"tsConfig": "apps/36-blocks/tsconfig.app.json",
"inlineStyleLanguage": "scss",
Expand Down
4 changes: 1 addition & 3 deletions apps/36-blocks/src/app/app.config.server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { ApplicationConfig } from '@angular/core';
import { provideServerRendering, withRoutes } from '@angular/ssr';
import { PERSISTENCE } from '@angular/fire/compat/auth';
import { serverRoutes } from './app.routes.server';

export const config: ApplicationConfig = {
providers: [provideServerRendering(withRoutes(serverRoutes)), { provide: PERSISTENCE, useValue: 'none' }],
providers: [{ provide: PERSISTENCE, useValue: 'none' }],
};
20 changes: 0 additions & 20 deletions apps/36-blocks/src/app/app.routes.server.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,6 @@
import { RenderMode, ServerRoute } from '@angular/ssr';

export const serverRoutes: ServerRoute[] = [
{
path: '',
renderMode: RenderMode.Prerender,
},
{
path: 'app/**',
renderMode: RenderMode.Client,
},
{
path: 'widget-preview/**',
renderMode: RenderMode.Client,
},
{
path: 'project',
renderMode: RenderMode.Client,
},
{
path: 'client/**',
renderMode: RenderMode.Client,
},
{
path: '**',
renderMode: RenderMode.Client,
Expand Down
2 changes: 1 addition & 1 deletion apps/36-blocks/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"outDir": "../../dist/out-tsc",
"types": ["node"]
},
"files": ["src/main.ts", "src/main.server.ts", "src/server.ts"],
"files": ["src/main.ts"],
"include": ["src/**/*.d.ts"],
"exclude": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts"]
}
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@
"@angular/material-moment-adapter": "21.2.2",
"@angular/platform-browser": "21.2.4",
"@angular/platform-browser-dynamic": "21.2.4",
"@angular/platform-server": "^21.2.4",
"@angular/router": "21.2.4",
"@angular/ssr": "^21.2.2",
"@highcharts/map-collection": "2.0.1",
"@materia-ui/ngx-monaco-editor": "6.0.0",
"@ngrx/component": "21.0.1",
Expand Down Expand Up @@ -100,7 +98,6 @@
"d3-transition": "3.0.1",
"dayjs": "1.11.7",
"echarts": "^6.0.0",
"express": "^5.2.1",
"firebase": "^12.10.0",
"froala-editor": "4.0.15",
"fs-extra": "5.0.0",
Expand Down Expand Up @@ -147,7 +144,6 @@
"@nx/workspace": "21.6.10",
"@schematics/angular": "21.2.2",
"@types/chart.js": "^2.9.28",
"@types/express": "^5.0.6",
"@types/jest": "29.5.14",
"@types/lodash": "^4.14.161",
"@types/lodash-es": "^4.17.3",
Expand Down
23 changes: 16 additions & 7 deletions tools/postbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,29 @@ readDir(path.join(__dirname, rootDirectiory))
});
})
.then(() => {
// Copy index.csr.html → app/index.html so static hosts (Amplify, S3, Nginx)
// can route /app/* to a clean Angular shell instead of the prerendered home page.
const csrHtmlPath = path.join(__dirname, rootDirectiory, 'index.csr.html');
// 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(csrHtmlPath)) {
if (fs.existsSync(distIndexPath)) {
if (!fs.existsSync(appShellDir)) {
fs.mkdirSync(appShellDir, { recursive: true });
}
fs.copyFileSync(csrHtmlPath, appShellPath);
console.log(`Copied index.csr.html → app/index.html`);

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.csr.html not found, skipping app/index.html copy');
console.log('index.html not found, skipping app/index.html copy');
}
})
.catch((err) => {
Expand Down
Loading