Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ElectronSettingsFilePath settings file is ignored? #243

Open
3 tasks done
dec opened this issue Sep 5, 2022 · 3 comments
Open
3 tasks done

ElectronSettingsFilePath settings file is ignored? #243

dec opened this issue Sep 5, 2022 · 3 comments

Comments

@dec
Copy link

dec commented Sep 5, 2022

Bug Report

Problem

I am having problems to set the app settings using the "ElectronSettingsFilePath" preference of the Cordova config.xml file.

What is expected to happen?

What is expected is that the settings are taken from the file which is indicated in the "ElectronSettingsFilePath" preference.

What does actually happen?

Apparently the specified settings file "ElectronSettingsFilePath" is ignored: no matter the changes that I made to this settings file, for example, changing the width and height of the window, these settings are not take in consideration when build the app.

I found a file "/platforms/electron/platform_www/cdv-electron-settings.json" which is what apparently electron is taken for the settings: certainly if I change this file settings, I can see it reflected in the build app.

Information

I am using the Cordova config.xml to place the below XML code:

<platform name="electron"> <preference name="ElectronSettingsFilePath" value="electron_settings.json" /> </platform>

And certainly I have a "electron_settings.json" file in the same folder than the config.xml file, however, this settings file are apparently ignored / not used when build the app.

This is the content of my test settings file: not too much, in fact I only change the "width" and the "height" to see if working, but, it's not working:

{
"browserWindow": {

"width": 320,    
"height": 480,

"resizable": false,

"webPreferences": {
  "nodeIntegration": true
}

}
}

Command or Code

CALL cordova platform add electron@latest
CALL cordova build electron --release

Environment, Platform, Device

I am using Microsoft Windows 11 with the latest version of Cordova and Cordova Electron.

Version information

Cordova CLI version: 11.0.0
Electron Builder version 22.14.13 os=10.0.22000

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

I appreciate any possible help with this issue. In fact I am near to assert that the config.xml file preference as well the settings file for Electron is working in the past as expected, however, I experienced this issue now and I really don't know how to proceed. So thanks very much in advance for any possible help or advice!

@dec
Copy link
Author

dec commented Sep 5, 2022

Hello to all,

Just to inform that I trying by forcing some specific version of Cordova Electron like 2.0.0 and 3.0.0... with the same result. Additionally, I try by using a different path in the "ElectronSettingsFilePath" value like:

<platform name="electron"> <preference name="ElectronSettingsFilePath" value="/electron_settings.json" /> </platform>

<platform name="electron"> <preference name="ElectronSettingsFilePath" value="./electron_settings.json" /> </platform>

<platform name="electron"> <preference name="ElectronSettingsFilePath" value=".\electron_settings.json" /> </platform>

... also with the same result... and it's rare, because I also use relative paths in the Cordova config.xml to set the installer icon, for example, and, in this case it's working as expected.

I am near to think that something is wrong here, because I can't believe this "error" is present, I mean, we are talking about to set the configuration file by the "ElectronSettingsFilePath": I see this working in the past, and, probably it's working now...

So there is something wrong in my own app / configuration, but I can't figure it out... since I try several things, paths, the settings file certainly exists, etc., so, I just can't figure out what can be happened.

Any possible help or advice is really appreciated! Thanks in advance for that!

@dec
Copy link
Author

dec commented Sep 5, 2022

Hello to all,

Finally I can found where is the problem! In my Cordova config.xml file, I have a couple of:

<platform name="electron">

In the first one I place the settings file path and the icons for the electron platform, and, in a second one I place the splash screen file path. When I remove the second "platform" XML tag, I can see that the settings file is now working as expected.

So for some reason Cordova Electron is "overridden" the first "platform" XML tag with the second one, which do not contain the settings file path.

It's a bit rare... because the first "platform" XML stuff contains the icons configuration, and, these are working as expected. So I am not sure why a second "platform" node specifically cause the ignoring of the settings file established in the first "platform" XML node.

Maybe this information can be useful for someone... or maybe this issue will be revised in order to see what is happening if we place a second "platform=electron" node in the Cordova config.xml file.

The point is that in my Cordova config.xml I have also a couple of "platform" nodes for the Android platform, and, apparently both of these nodes are taken and used without problems, so, maybe this must be also the expected behaviour for the case of the electron platform.

@dec
Copy link
Author

dec commented Sep 5, 2022

Hello to all,

A bit more of information about this issue. I mention that I have a couple of "platform=electron" nodes in my Cordova config.xml file. Ok, if I move the "ElectronSettingsFilePath" seeting to the second "platform=electron" node, then the configuration file is also loaded / taken as expected.

So to me is like if the XML parser take the "ElectronSettingsFilePath" setting from the last "platform=electron" node: if not exists, no matter if exists in the first node, the configuration file is not loaded / taken as expected. Maybe this information can be useful in some manner!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant