Home  >  Q&A  >  body text

Sharing nw.js binaries with applications in subfolders: A guide to efficient distribution

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粉465287592P粉465287592276 days ago469

reply all(1)I'll reply

  • P粉163951336

    P粉1639513362024-01-18 00:16:15

    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.

    reply
    0
  • Cancelreply