Browse Source

ssr removed from app template

pull/23416/head
erdemcaygor 12 months ago
parent
commit
1234b8e70f
  1. 77
      templates/app/angular/angular.json
  2. 2
      templates/app/angular/package.json
  3. 2
      templates/app/angular/src/app/app.config.ts
  4. 2
      templates/app/angular/src/main.ts
  5. 69
      templates/app/angular/src/server_legacy.ts
  6. 3
      templates/app/angular/tsconfig.app.json
  7. 1
      templates/app/angular/tsconfig.json

77
templates/app/angular/angular.json

@ -21,22 +21,14 @@
"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"
],
"polyfills": ["src/polyfills.ts"],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"allowedCommonJsDependencies": [
"chart.js",
"js-sha256"
],
"assets": [
"src/favicon.ico",
"src/assets"
],
"allowedCommonJsDependencies": ["chart.js", "js-sha256"],
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
{
"input": "node_modules/@fortawesome/fontawesome-free/css/all.min.css",
@ -188,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"
}
}
}

2
templates/app/angular/package.json

@ -29,9 +29,7 @@
"@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",
"rxjs": "~7.8.0",
"tslib": "^2.0.0",

2
templates/app/angular/src/app/app.config.ts

@ -17,7 +17,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, withHttpTransferCacheOptions} from '@angular/platform-browser';
export const appConfig: ApplicationConfig = {
providers: [
@ -40,6 +39,5 @@ export const appConfig: ApplicationConfig = {
provideFeatureManagementConfig(),
provideAnimations(),
provideLogo(withEnvironmentOptions(environment)),
provideClientHydration(withEventReplay(), withHttpTransferCacheOptions({}))
],
};

2
templates/app/angular/src/main.ts

@ -1,5 +1,5 @@
import { bootstrapApplication } from '@angular/platform-browser';
import {appConfig} from './app/app.config';
import { appConfig } from './app/app.config';
import { AppComponent } from './app/app.component';
bootstrapApplication(AppComponent, appConfig).catch(err => console.error(err));

69
templates/app/angular/src/server_legacy.ts

@ -1,69 +0,0 @@
import 'zone.js/node';
import { APP_BASE_HREF } from '@angular/common';
import { CommonEngine } from '@angular/ssr/node';
import * as 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);
// Example Express Rest API endpoints
// server.get('/api/**', (req, res) => { });
// Serve static files from /browser
server.get('*.*', express.static(distFolder, {
maxAge: '1y'
}));
// All regular routes use the Angular engine
server.get('*', (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, () => {
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;

3
templates/app/angular/tsconfig.app.json

@ -7,8 +7,7 @@
},
"files": [
"src/main.ts",
"src/polyfills.ts",
"src/server.ts"
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"

1
templates/app/angular/tsconfig.json

@ -6,6 +6,7 @@
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "bundler",
"importHelpers": true,

Loading…
Cancel
Save