Skip to content

Commit 53c89e6

Browse files
authored
fix: fast svg build (#349)
1 parent 2865588 commit 53c89e6

File tree

3 files changed

+11771
-9063
lines changed

3 files changed

+11771
-9063
lines changed

apps/blog/src/app/app.config.server.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
import { readFileSync } from 'node:fs';
1+
import { readFile } from 'node:fs/promises';
22
import { join } from 'node:path';
3+
import { cwd } from 'node:process';
34
import {
45
ApplicationConfig,
56
Injectable,
67
mergeApplicationConfig,
78
} from '@angular/core';
89
import { provideServerRendering } from '@angular/platform-server';
9-
import { Observable, of } from 'rxjs';
10-
1110
import { provideFastSVG, SvgLoadStrategy } from '@push-based/ngx-fast-svg';
11+
import { from, Observable, of, switchMap } from 'rxjs';
1212

1313
import { appConfig } from './app.config';
1414

1515
@Injectable()
1616
export class SvgLoadStrategySsr implements SvgLoadStrategy {
17-
load(url: string): Observable<string> {
18-
const iconPath = join(process.cwd(), 'apps', 'blog', 'src', url);
19-
const iconSVG = readFileSync(iconPath, 'utf8');
20-
return of(iconSVG);
17+
config(url: string) {
18+
return of(join(cwd(), 'apps', 'blog', 'src', url));
19+
}
20+
load(iconPath$: Observable<string>) {
21+
return iconPath$.pipe(
22+
switchMap((iconPath) => from(readFile(iconPath, { encoding: 'utf8' }))),
23+
);
2124
}
2225
}
2326

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"@ngrx/operators": "^17.2.0",
3939
"@ngrx/signals": "^17.0.1",
4040
"@nx/angular": "19.5.1",
41-
"@push-based/ngx-fast-svg": "^18.0.0",
41+
"@push-based/ngx-fast-svg": "^18.1.0",
4242
"@tailwindcss/container-queries": "^0.1.1",
4343
"algoliasearch": "^4.23.3",
4444
"cheerio": "1.0.0-rc.12",

0 commit comments

Comments
 (0)