Node PostProcessor step for Angular and Electron.
If we try to start in Electron environment program created by Angular - we receive error, because Electron don't understand where is root of application:


Therefore we need to little bit changing link in HTML (add "./"). This is "post-processor" step in my Angular-Electron template https://github.com/Alex1998100/AngularElectron/tree/PostProcessor.


Something tiny program what adding "./" to result of Angular.
1: const fs = require('fs');
2: const path = require('path');
3:
4: const indexPath = path.join(__dirname, '..', 'dist', 'angular-electron1', 'browser', 'index.html');
5:
6: function updateIndexHtml() {
7: try {
8: let html = fs.readFileSync(indexPath, 'utf-8');
9: if (html.includes('<base href="./"')) {
10: console.log('Base href already correct. Skipping update.');
11: return;
12: }
13: html = html.replace('<base href="/"', '<base href="./"');
14: html = html.replace(/ (href|src)="([^"]+)"/g, (match, attribute, value) => {
15: if (value === "favicon.ico") return match;
16: if (value.startsWith("./")) return match;
17: return ` ${attribute}="./${value}"`;
18: });
19: fs.writeFileSync(indexPath, html);
20: console.log('index.html updated successfully.');
21: } catch (error) {
22: console.error('Error updating index.html:', error);
23: }
24: }
25:
26: updateIndexHtml();
Post processor is usual template to Vs2022, rarely does a project go without post-processing in this place in Vs2022:

But in Vs Code we should use another way, like in my scenario:
"scripts": { "post-processor": "node ./tools/post-processor.js", "electron:start": "npm run build:angular && npm run build:electron-main && npm run post-processor && npx cross-env NODE_ENV=development electron .",
NodeBackend context:
- (2024) Example of my Node Express server code to read image and save it to Amazon S3 #NodeBackend
- (2024) Best REST client for Node and VS.CODE #NodeBackend
- (2024) Common Node.js backend logic (plus some of my YUP filters) #NodeBackend
- (2024) Refactoring Boompfi/Strip gateway to subscription mode #NodeBackend
- (2024) My workable Node mailing templates (with Brevo and Resend Post servers, on JS and TS with Dotenv, with native packages and directly with fetching API, with sync/async/IIFE templates) #NodeBackend
- (2024) My workable Node templates with MySQL and PostgreSQL without ORM (with and without connection pool). #NodeBackend
- (2024) Node PostProcessor step for Angular and Electron. #Angular #Electron #NodeBackend
- (2024) Parse CSV with Node. #NodeBackend
- (2024) Node project for support this blog #NodeBackend
- (2024) Test project with Nest.js and Sequelize ORM #NodeBackend
- (2023) Server Angular (NestJs) learning. #NodeBackend
- (2023) Brief of real workable NestJs application. #NodeBackend
- (2023) Node.JS Configuration - set Angular, Typescript, Nativescript, NPM custom location. #NodeBackend
- (2021) Use SignalRSwaggerGen to create Swagger specification of SignalR hub #NodeBackend
Angular context:
- (2025) Loading images asynchronously (Angular, Axios, jQuery, XMLHttpRequest, Html5). Angular async pipe with Promise and Observable. #Browser #FrontLearning #Angular
- (2024) Example of my Async Angular code (async chain with Fetch site icon plus async save to storage) with ActivityIndicator on frontend #Angular #Nativescript
- (2024) NativeScript and Angular form #Angular #JavascriptProjects #Nativescript
- (2024) MyVault Android phone application #Android #Angular #JavascriptProjects
- (2024) My workable project template for Angular Electron #Angular #Electron
- (2024) Node PostProcessor step for Angular and Electron. #Angular #Electron #NodeBackend
- (2023) 5 way to create modal windows with Angular (Angular material, UIKit with toggle tag, UIKit with custom function, jQuery UI modal, Bootstrap modal). #Angular #JavascriptProjects
- (2023) [Angular mosaic 1] My fast style, Intercept routing events (router-outlet onActivate event, @Input, extends base page). #Angular #JavascriptProjects
- (2023) [Angular mosaic 2] Simplest shared service (@Injectable, Subject, Injectable, LocalStorage, Store), UIkit Modal Futures (uk-modal tag, Modal from routed page and from Menu, Modal Toggle, Modal Show, Bind by On, MouseOver Modal, Modal Alert, Modal Prompt, Close button). #Angular
- (2023) [Angular mosaic 3] Standard Interceptor and JWT injector, Login page, Auth service, and Base form with FormGroup. #NetCoreBackend #Angular
- (2023) [Angular mosaic 4] Fill select/options (FormsModule, ngModel, ngModelChange, ngValue, http.get Json from Assets, LocalStorage), Angular connection service (Enable/Disable Heartbeat, Heartbeat URL, Heartbeat Interval/RetryInterval). #Angular
- (2023) [Angular mosaic 5] Net Core SignalR Client (ReactiveX/rxjs, Configure Angular injector, Abstract class, Inject SignalR service, Configure SignalR hub - forbid Negotiation, setUp Transport, URL, LogLevel, Anon or AU socket connection), Configure server Hub (MapHub endpoint, WithOrigins on CORS-policy, LogLevel, JWT AU) #NetCoreBackend #Angular
- (2023) Notes about most interesting project in my life. #Crypto #Blazor #Angular #Kvm #Linux #Ssl #NetCoreBackend #Servers #VmWare #Docker
- (2023) Server Angular (NestJs) learning. #Angular #FrontLearning
- (2022) Key future of RPAT backend project #Excel #Cloud #Browser #EfCodeFirst #TimeSchedule #NetCoreBackend #Angular
- (2022) Scaffolding Angular Client From Swagger.json #Angular #NetCoreBackend
- (2022) Setup Angular proxy #Angular
- (2022) Remote debugging Angular project with VS Code (Firefox) #Browser #Angular
- (2022) Processing Backend result in Angular frontend as typed data #Angular #NetCoreBackend
- (2022) Up and running Angular application on Android mobile phone with NativeScript. #Angular #Nativescript #Android
Electron context:
- (2024) Electron video player with cashing and CSP policy #Electron #Video
- (2024) My workable project template for Angular Electron #Angular #Electron
- (2024) Node PostProcessor step for Angular and Electron. #Angular #Electron #NodeBackend
- (2022) Electron learning #FrontLearning #Electron
- ...
- (2024) Browser Window Options in Electron application.
- (2024) Important Parameters in Electron application.
- (2024) Core Features and Concepts in Electron application.
- (2024) Crucial Programming Techniques in Electron application.
- (2024) Main Process vs. Renderer Process in Electron application.
- (2024) Inter-Process Communication in Electron application.
- (2024) Asynchronous Operations in Electron application.
- (2024) Databases in Electron application.
- (2024) MySQL and PostgreSQL integration in Electron application.
- (2024) LocalStorage in Electron application.
- (2024) Native Modules in Electron application.
- (2024) Electron APIs in Electron application.
- (2024) Multi-window Applications in Electron application.
- (2024) Packaging and Distribution in Electron application.
- (2024) Node Integration in Electron application.
- (2024) Memory Leaks in Electron application.
- (2024) Code Security in Electron application.
- (2024) Browser Automation in Electron application.
- (2024) Testing in Electron application.
- (2024) Monetization in Electron application.
Comments (
)

Link to this page:
http://www.vb-net.com/NodePostProcessor/Index.htm
|