Sharing nw.js binaries with applications in subfolders: A guide to efficient distribution
P粉465287592
P粉465287592 2024-01-17 08:58:39
0
1
528

So I've got the following problem: My project (this one) depends on two different nw.js applications bundled using web2exe. One of them is for setup and the other is GUI-less and should run in the background on startup. The second application also relies on nw to implement operations such as showing tray icons and hiding windows that would otherwise require platform-specific scripts such as batch files or shell scripts. This solution works fine, but I can't compress the executable since the system needs to access some normal files in the tree. Even if it could, the largest files would be the dll and locale files. Bundling two separate, uncompressed web applications with additional node modules would result in a file size of around 800mb, which is completely unrealistic for what I want to achieve with my application.

I'm considering using another framework, such as Neutralinojs, but that means having to rewrite the code and losing some new specific functionality in the process. I'm more interested in sharing new files between my two applications. The second one is in a subfolder of the first one. Most nw files (except the executable itself) are identical to the files in the root nw directory. In particular, sharing the nw.dll and locales folders between them has reduced the size by about 200mb.

I've been looking for ways to do this, but so far I haven't found any good methods. Maybe there's a solution here that I'm missing. Another solution I can imagine is to use some smaller subset or reimplement nw using native webview. Maybe there is something similar out there, but I haven't found it yet.

P粉465287592
P粉465287592

reply all(1)
P粉163951336

The easiest solution is to simply combine them into one application.

  1. Change FelizJueves' main in package.json to a JS file instead of an HTML file.
  2. Make JS script your background process. Don't open the window, just do whatever you are currently doing in FelizCheck.
  3. In this JS script, listen for the open event: https://nwjs.readthedocs.io/en/latest/References/App/#event-openargs
  4. In the open event handler, use nw.Window.open() to display the window (FelizJueves.html). This event is fired when someone attempts to start an application that is already running. So the first launch just starts the background checker. The UI window will pop up the second time you start it.
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template