From version 20.0.0 of electron, preload process is now sandboxed by default electron #32869
This causes titlebar to throw errors when attempting to fetch node fs module used to read the custom user provided icon json file.
Updated titlebar.ts to remove the import of fs module and directly pass a dictionary of the json file instead of reading it from disk.
Using a bundler like webpack for the preload.js script could work like this (not tested):
import { Titlebar, Color } from 'custom-electron-titlebar';
import icon from './assets/images/icon.svg';
import icons from './assets/icons.json';
let titlebar;
window.addEventListener('DOMContentLoaded', () => {
titlebar = new Titlebar({
backgroundColor: Color.fromHex("#388e3c"),
itemBackgroundColor: Color.fromHex("#121212"),
svgColor: Color.WHITE,
icon: icon,
icons: icons,
//menu: null // = do not automatically use Menu.applicationMenu
})
From version 20.0.0 of electron, preload process is now sandboxed by default electron #32869
This causes
titlebar
to throw errors when attempting to fetch node fs module used to read the custom user provided icon json file.Updated
titlebar.ts
to remove the import of fs module and directly pass a dictionary of the json file instead of reading it from disk.Using a bundler like webpack for the
preload.js
script could work like this (not tested):