Skip to content

Commit

Permalink
ci: add compression for ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Mar 29, 2024
1 parent 66aeb22 commit 2c5b2fb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions projects/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"devDependencies": {
"@angular-builders/custom-webpack": "16.0.1",
"@nguniversal/builders": "16.2.0",
"@types/compression": "1.7.5",
"@types/express": "4.17.21",
"compression": "1.7.4",
"express": "4.19.2",
"terser-webpack-plugin": "5.3.10"
}
Expand Down
10 changes: 10 additions & 0 deletions projects/demo/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import 'zone.js/node';

import {existsSync} from 'node:fs';
import {join} from 'node:path';
import * as zlib from 'node:zlib';

import {APP_BASE_HREF} from '@angular/common';
import {provideLocation, provideUserAgent} from '@ng-web-apis/universal';
import {ngExpressEngine} from '@nguniversal/express-engine';
import compression from 'compression';
import express from 'express';

import bootstrap from './src/main.server';
Expand All @@ -31,6 +33,14 @@ if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
const server = express();
const dist = join(process.cwd(), 'dist/demo/browser');

server.use(
compression({
level: 9,
memLevel: 9,
strategy: zlib.constants.Z_HUFFMAN_ONLY,
}),
);

server.engine('html', ngExpressEngine({bootstrap}));
server.set('view engine', 'html');
server.set('views', dist);
Expand Down

0 comments on commit 2c5b2fb

Please sign in to comment.