2

I'm trying to integrate Neutralinojs with Vite to improve my dev workflow and use HMR. How should I configure the setup for HMR to function properly? I've tried both in macOS and Windows without luck.

I’ve followed the Neutralinojs docs. I've succeeded to use assets written to disk by using Vite's watch mode (vite build --watch). However, this causes a full refresh of the application.

I start the development servers in two separate terminals with the following commands:

  1. vite
  2. npx @neutralinojs/neu run -- --frontend-lib-dev --window-enable-inspector

Below are my configuration files.

vite.config.js

export default defineConfig({
  build: {
    outDir: "dist",
    emptyOutDir: false
  },
  server: {
    port: 3000
  }
});

neutralino.config.json

{
  "applicationId": "js.neutralino.zero",
  "version": "1.0.0",
  "defaultMode": "window",
  "port": 0,
  "documentRoot": "/dist/",
  "url": "/",
  "enableServer": true,
  "enableNativeAPI": true,
  "exportAuthInfo": true,
  "nativeAllowList": [
    "app.*"
  ],
  "modes": {
    "window": {
      "title": "neu-vite",
      "width": 800,
      "height": 500,
      "minWidth": 400,
      "minHeight": 200,
      "icon": "/public/appIcon.png"
    }
  },
  "cli": {
    "binaryName": "neu-vite",
    "resourcesPath": "/dist/",
    "extensionsPath": "/extensions/",
    "clientLibrary": "/public/neutralino.js",
    "binaryVersion": "4.12.0",
    "clientVersion": "3.10.0",
    "frontendLibrary": {
      "patchFile": "/index.html",
      "devUrl": "http://localhost:3000"
    }
  }
}
Jouni Kantola
  • 1,097
  • 7
  • 12

1 Answers1

1

I think to use your local you need to provide server.hmr in your config

enter image description here

server: {
   port:3000,
   hmr: {
     host: 'localhost',
     port:7859,
   },
Sweety SK
  • 351
  • 1
  • 10