javascriptpreactneutralinojs

Built Neutralino app cannot open localhost?


I have a very peculiar issue, I have a Neutralino app built with Preact that runs perfectly fine when run with neu run, however, once I build the project (with enableServer on or off), the built application will not load anything.

With enableServer on, it will complain that it cannot connect to localhost: "This localhost page cannot be found"

and with it off it gives me a completely white screen/DOM.

The GitHub repository is here: https://github.com/SpikeHD/XeniaLauncher

I suspect it may be the way I am building the project, but I find it weird that neu run works completely fine.

Below is my configuration:

{
  "applicationId": "js.xenia_launcher.app",
  "version": "1.0.0",
  "defaultMode": "window",
  "port": 0,
  "documentRoot": "/build/",
  "url": "/",
  "enableServer": true,
  "enableNativeAPI": true,
  "tokenSecurity": "one-time",
  "logging": {
    "enabled": true,
    "writeToLogFile": true
  },
  "nativeAllowList": [
    "app.*",
    "os.*",
    "filesystem.*",
    "storage.*",
    "window.*",
    "debug.log"
  ],
  "modes": {
    "window": {
      "title": "XeniaLauncher",
      "width": 1000,
      "height": 800,
      "minWidth": 400,
      "minHeight": 200,
      "fullScreen": false,
      "alwaysOnTop": false,
      "icon": "/resources/icons/appIcon.png",
      "enableInspector": true,
      "borderless": false,
      "maximize": false,
      "hidden": false,
      "resizable": true,
      "exitProcessOnClose": true
    },
    "browser": {},
    "cloud": {
      "url": "/resources/#cloud",
      "nativeAllowList": [
        "app.*"
      ]
    },
    "chrome": {
      "width": 1000,
      "height": 800,
      "args": "--user-agent=\"Neutralinojs chrome mode\""
    }
  },
  "cli": {
    "binaryName": "XeniaLauncher",
    "resourcesPath": "/resources/",
    "extensionsPath": "/extensions/",
    "clientLibrary": "/resources/js/neutralino.js",
    "binaryVersion": "4.4.0",
    "clientVersion": "3.3.0"
  }
}

Solution

  • Fixed it! I ended up just setting up some scripts that will put all the built Preact code into the resources folder and re-setup my config to only use the resources folder, like the original Neutralino template. I am sure there could have been a more elegant way, but I am still just learning Neutralino and Preact so this works perfectly well enough for me.