From 5e6e8370108d1c0cf286536bacc1b4478c609e02 Mon Sep 17 00:00:00 2001 From: erdemcaygor Date: Tue, 2 Sep 2025 11:46:27 +0300 Subject: [PATCH] application builder added to app-nolayers template --- templates/app-nolayers/angular/angular.json | 63 +------------- templates/app-nolayers/angular/package.json | 8 +- .../angular/src/app/app.config.server.ts | 14 ---- .../angular/src/app/app.config.ts | 1 - .../angular/src/app/app.routes.server.ts | 24 ------ .../app-nolayers/angular/src/main.server.ts | 7 -- templates/app-nolayers/angular/src/server.ts | 82 ------------------- templates/app-nolayers/angular/tsconfig.json | 1 + .../app-nolayers/angular/tsconfig.server.json | 16 ---- 9 files changed, 4 insertions(+), 212 deletions(-) delete mode 100644 templates/app-nolayers/angular/src/app/app.config.server.ts delete mode 100644 templates/app-nolayers/angular/src/app/app.routes.server.ts delete mode 100644 templates/app-nolayers/angular/src/main.server.ts delete mode 100644 templates/app-nolayers/angular/src/server.ts delete mode 100644 templates/app-nolayers/angular/tsconfig.server.json diff --git a/templates/app-nolayers/angular/angular.json b/templates/app-nolayers/angular/angular.json index 31fa9c3f1c..6ed0811fb5 100644 --- a/templates/app-nolayers/angular/angular.json +++ b/templates/app-nolayers/angular/angular.json @@ -21,7 +21,7 @@ "build": { "builder": "@angular-devkit/build-angular:application", "options": { - "outputPath": "dist/MyProjectName/browser", + "outputPath": "dist/MyProjectName", "index": "src/index.html", "browser": "src/main.ts", "polyfills": ["src/polyfills.ts"], @@ -180,67 +180,6 @@ "options": { "lintFilePatterns": ["src/**/*.ts", "src/**/*.html"] } - }, - "server": { - "builder": "@angular-devkit/build-angular:server", - "options": { - "outputPath": "dist/MyProjectName/server", - "main": "src/server.ts", - "tsConfig": "tsconfig.server.json", - "inlineStyleLanguage": "scss" - }, - "configurations": { - "production": { - "outputHashing": "media", - "fileReplacements": [ - { - "replace": "src/environments/environment.ts", - "with": "src/environments/environment.prod.ts" - } - ] - }, - "development": { - "buildOptimizer": false, - "optimization": false, - "sourceMap": true, - "extractLicenses": false, - "vendorChunk": true - } - }, - "defaultConfiguration": "production" - }, - "serve-ssr": { - "builder": "@angular-devkit/build-angular:ssr-dev-server", - "configurations": { - "development": { - "browserTarget": "MyProjectName:build:development", - "serverTarget": "MyProjectName:server:development" - }, - "production": { - "browserTarget": "MyProjectName:build:production", - "serverTarget": "MyProjectName:server:production" - } - }, - "defaultConfiguration": "development" - }, - "prerender": { - "builder": "@angular-devkit/build-angular:prerender", - "options": { - "routes": [ - "/" - ] - }, - "configurations": { - "production": { - "browserTarget": "MyProjectName:build:production", - "serverTarget": "MyProjectName:server:production" - }, - "development": { - "browserTarget": "MyProjectName:build:development", - "serverTarget": "MyProjectName:server:development" - } - }, - "defaultConfiguration": "production" } } } diff --git a/templates/app-nolayers/angular/package.json b/templates/app-nolayers/angular/package.json index 9791e46fa1..28968630be 100644 --- a/templates/app-nolayers/angular/package.json +++ b/templates/app-nolayers/angular/package.json @@ -29,11 +29,8 @@ "@angular/localize": "~20.0.0", "@angular/platform-browser": "~20.0.0", "@angular/platform-browser-dynamic": "~20.0.0", - "@angular/platform-server": "~20.0.0", "@angular/router": "~20.0.0", - "@angular/ssr": "~20.0.0", "bootstrap-icons": "~1.8.0", - "express": "~5.1.0", "rxjs": "~7.8.0", "tslib": "^2.0.0", "zone.js": "~0.15.0" @@ -49,12 +46,11 @@ "@angular/cli": "~20.0.0", "@angular/compiler-cli": "~20.0.0", "@angular/language-service": "~20.0.0", - "@types/express": "~5.0.0", + "@angular/build": "~20.0.0", "@types/jasmine": "~3.6.0", - "@types/node": "~20.11.0", + "@types/node": "^12.11.1", "@typescript-eslint/eslint-plugin": "7.16.0", "@typescript-eslint/parser": "7.16.0", - "browser-sync": "^3.0.0", "eslint": "^8.0.0", "jasmine-core": "~4.0.0", "karma": "~6.3.0", diff --git a/templates/app-nolayers/angular/src/app/app.config.server.ts b/templates/app-nolayers/angular/src/app/app.config.server.ts deleted file mode 100644 index 3b6fd1ec1e..0000000000 --- a/templates/app-nolayers/angular/src/app/app.config.server.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { mergeApplicationConfig, ApplicationConfig } from '@angular/core'; -import {provideServerRendering, withRoutes} from '@angular/ssr'; -import { appConfig } from './app.config'; -import {provideAbpOAuth} from "@abp/ng.oauth"; -import {serverRoutes} from "./app.routes.server"; - -const serverConfig: ApplicationConfig = { - providers: [ - provideAbpOAuth(), - provideServerRendering(withRoutes(serverRoutes)) - ] -}; - -export const config = mergeApplicationConfig(appConfig, serverConfig); diff --git a/templates/app-nolayers/angular/src/app/app.config.ts b/templates/app-nolayers/angular/src/app/app.config.ts index 128d230ae4..69d4496706 100644 --- a/templates/app-nolayers/angular/src/app/app.config.ts +++ b/templates/app-nolayers/angular/src/app/app.config.ts @@ -16,7 +16,6 @@ import { provideFeatureManagementConfig } from '@abp/ng.feature-management'; import { provideThemeLeptonX } from '@abp/ng.theme.lepton-x'; import { provideSideMenuLayout } from '@abp/ng.theme.lepton-x/layouts'; import { provideLogo, withEnvironmentOptions } from '@volo/ngx-lepton-x.core'; -import { provideClientHydration, withEventReplay } from '@angular/platform-browser'; export const appConfig: ApplicationConfig = { providers: [ diff --git a/templates/app-nolayers/angular/src/app/app.routes.server.ts b/templates/app-nolayers/angular/src/app/app.routes.server.ts deleted file mode 100644 index 0c0731eb1c..0000000000 --- a/templates/app-nolayers/angular/src/app/app.routes.server.ts +++ /dev/null @@ -1,24 +0,0 @@ -import {RenderMode, ServerRoute} from "@angular/ssr"; - -export const serverRoutes: ServerRoute[] = [ - { - path: '', - renderMode: RenderMode.Server - }, - { - path: 'account', - renderMode: RenderMode.Server - }, - { - path: 'identity', - renderMode: RenderMode.Server - }, - { - path: 'tenant-management', - renderMode: RenderMode.Server - }, - { - path: 'setting-management', - renderMode: RenderMode.Server - }, -]; diff --git a/templates/app-nolayers/angular/src/main.server.ts b/templates/app-nolayers/angular/src/main.server.ts deleted file mode 100644 index 4b9d4d1545..0000000000 --- a/templates/app-nolayers/angular/src/main.server.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { bootstrapApplication } from '@angular/platform-browser'; -import { AppComponent } from './app/app.component'; -import { config } from './app/app.config.server'; - -const bootstrap = () => bootstrapApplication(AppComponent, config); - -export default bootstrap; diff --git a/templates/app-nolayers/angular/src/server.ts b/templates/app-nolayers/angular/src/server.ts deleted file mode 100644 index d0a097c9bf..0000000000 --- a/templates/app-nolayers/angular/src/server.ts +++ /dev/null @@ -1,82 +0,0 @@ -import 'zone.js/node'; - -import { APP_BASE_HREF } from '@angular/common'; -import { CommonEngine } from '@angular/ssr/node'; -import express from 'express'; -import { existsSync } from 'node:fs'; -import { join } from 'node:path'; -import bootstrap from './main.server'; - -// 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/MyProjectName/browser'); - const indexHtml = existsSync(join(distFolder, 'index.original.html')) - ? join(distFolder, 'index.original.html') - : join(distFolder, 'index.html'); - - const commonEngine = new CommonEngine(); - - server.set('view engine', 'html'); - server.set('views', distFolder); - - server.get('/.well-known/appspecific/com.chrome.devtools.json', (req, res) => { - res.status(404).send('Not Found'); - }); - - // Example Express Rest API endpoints - // server.get('/api/{*splat}', (req, res) => { }); - // Serve static files from /browser - server.use(express.static(distFolder, { - maxAge: '1y', - index: false, - })); - - server.get('/.well-known/*', (req, res) => { - res.status(404).send('Not found'); - }); - - // All regular routes use the Angular engine - server.use((req, res, next) => { - const { protocol, originalUrl, baseUrl, headers } = req; - - commonEngine - .render({ - bootstrap, - documentFilePath: indexHtml, - url: `${protocol}://${headers.host}${originalUrl}`, - publicPath: distFolder, - providers: [{ provide: APP_BASE_HREF, useValue: baseUrl }], - }) - .then((html) => res.send(html)) - .catch((err) => next(err)); - }); - - return server; -} - -function run(): void { - const port = process.env['PORT'] || 4000; - - // Start up the Node server - const server = app(); - server.listen(port, (error) => { - if (error) { - throw error; - } - - console.log(`Node Express server listening on http://localhost:${port}`); - }); -} - -// Webpack will replace 'require' with '__webpack_require__' -// '__non_webpack_require__' is a proxy to Node 'require' -// The below code is to ensure that the server is run only when not requiring the bundle. -declare const __non_webpack_require__: NodeRequire; -const mainModule = __non_webpack_require__.main; -const moduleFilename = mainModule && mainModule.filename || ''; -if (moduleFilename === __filename || moduleFilename.includes('iisnode')) { - run(); -} - -export default bootstrap; diff --git a/templates/app-nolayers/angular/tsconfig.json b/templates/app-nolayers/angular/tsconfig.json index 0322d97e4d..eeb0e33782 100644 --- a/templates/app-nolayers/angular/tsconfig.json +++ b/templates/app-nolayers/angular/tsconfig.json @@ -6,6 +6,7 @@ "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, + "downlevelIteration": true, "experimentalDecorators": true, "moduleResolution": "bundler", "importHelpers": true, diff --git a/templates/app-nolayers/angular/tsconfig.server.json b/templates/app-nolayers/angular/tsconfig.server.json deleted file mode 100644 index 1166d1a0aa..0000000000 --- a/templates/app-nolayers/angular/tsconfig.server.json +++ /dev/null @@ -1,16 +0,0 @@ -/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */ -/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */ -{ - "extends": "./tsconfig.app.json", - "compilerOptions": { - "outDir": "./out-tsc/server", - "types": [ - "node", - "@angular/localize" - ] - }, - "files": [ - "src/main.server.ts", - "src/server.ts" - ] -}