diff --git a/angular.json b/angular.json index 3ff4f70e5a9..7673791eebf 100644 --- a/angular.json +++ b/angular.json @@ -120,6 +120,6 @@ } }, "cli": { - "analytics": false + "analytics": false } } \ No newline at end of file diff --git a/package.json b/package.json index 5a0b0e9d8ec..151f872fd23 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "type": "git", "url": "https://github.com/primefaces/primeng.git" }, + "type": "module", "devDependencies": { "@angular-devkit/build-angular": "^17.3.1", "@angular-eslint/eslint-plugin": "17.3.0", diff --git a/server.ts b/server.ts index d5e8374acef..d014abb7186 100644 --- a/server.ts +++ b/server.ts @@ -1,27 +1,28 @@ import { APP_BASE_HREF } from '@angular/common'; import { CommonEngine } from '@angular/ssr'; import express from 'express'; -import { join } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { dirname, join, resolve } from 'node:path'; import bootstrap from './src/main.server'; -import { environment } from 'src/environments/environment'; // The Express app is exported so that it can be used by serverless Functions. export function app(): express.Express { const server = express(); - const distFolder = join(process.cwd(), 'dist/primeng/browser'); - const indexHtml = join(distFolder, 'index.html'); + const serverDistFolder = dirname(fileURLToPath(import.meta.url)); + const browserDistFolder = resolve(serverDistFolder, '../browser'); + const indexHtml = join(serverDistFolder, 'index.server.html'); const commonEngine = new CommonEngine(); server.set('view engine', 'html'); - server.set('views', distFolder); + server.set('views', browserDistFolder); // Example Express Rest API endpoints // server.get('/api/**', (req, res) => { }); // Serve static files from /browser server.get( '*.*', - express.static(distFolder, { + express.static(browserDistFolder, { maxAge: '1y' }) ); @@ -35,7 +36,7 @@ export function app(): express.Express { bootstrap, documentFilePath: indexHtml, url: `${protocol}://${headers.host}${originalUrl}`, - publicPath: distFolder, + publicPath: browserDistFolder, providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }] }) .then((html) => res.send(html)) @@ -44,3 +45,15 @@ export function app(): express.Express { return server; } + +function run(): void { + const port = process.env['PORT'] || 4000; + + // Start up the Node server + const server = app(); + server.listen(port, () => { + console.log(`Node Express server listening on http://localhost:${port}`); + }); +} + +run(); diff --git a/src/app/showcase/data/news.json b/src/app/showcase/data/news.json index 93f4882a03d..11e037f46b1 100644 --- a/src/app/showcase/data/news.json +++ b/src/app/showcase/data/news.json @@ -2,5 +2,5 @@ "id": 63, "content": "Introducing the new Aura theme", "linkText": "Learn More", - "linkHref": "http://localhost:4200/theming" + "linkHref": "https://primeng.org/theming" } diff --git a/src/app/showcase/layout/topbar/app.topbar.component.html b/src/app/showcase/layout/topbar/app.topbar.component.html index a464bcb8991..98d5c8a55b9 100644 --- a/src/app/showcase/layout/topbar/app.topbar.component.html +++ b/src/app/showcase/layout/topbar/app.topbar.component.html @@ -94,9 +94,9 @@