Hi all,

I finally merged my PR [1] which improves the development server for the 
D-Installer
frontend. It completely changed how it works.

Now the dev server serves the D-Installer Cockpit plugin and the Hot Module Replacement end point. It redirects all Cockpit requests to another server,
it works like a proxy.

To start the dev server use this command:

  COCKPIT_TARGET=<IP_or_HOSTNAME> npm run server

Where COCKPIT_TARGET is the IP address or hostname of the running D-Installer
instance. If you do not set that variable it will by default connect to the local server (at https://localhost:9090).

Then open https://localhost:8080 in your browser or use "npm run server -- 
--open"
to open it automatically.

It generates a self-signed SSL certificate, you have to accept it in the first
connection in the browser. The generated certificate is saved to a cache
and is used next time so you have to accept it just once.

See more details in the documentation [2].


What are the advantages?

- You do not need to run the web frontend on the same machine as the backend

  - I'm running Leap 15.4 on my workstation, Cockpit is not available for this
    release so I cannot run it against the local Cockpit instance. That makes 
the
    development very difficult.
  - I can run the D-Installer backend using the Live ISO in a VM, that makes the
    development more safe, I cannot delete my disks accidentally when starting 
the
    installation :)
  - I can use my Visual Studio Code installed locally, you can use your 
preferred
    editor as well ;-)
  - Actually you could even use a different distro, you just need nodejs + npm
    and some editor for developing the frontend.

- The hot module replacement [3] now fully works, you will see your changes
  in the browser immediately after saving a file without reloading the page.

- The previous approach used some hacks and did not integrate well (mixed 
different
  protocols (https vs http), used different hosts and ports on the same
  page -  browsers do not like that and block that because of security).
  That has been removed.


Enjoy :-)

Ladislav


[1] https://github.com/yast/d-installer/pull/439
[2] 
https://github.com/yast/d-installer/tree/master/web#using-a-development-server
[3] https://webpack.js.org/concepts/hot-module-replacement/


--
Ladislav Slezák
YaST Developer

SUSE LINUX, s.r.o.
Corso IIa
Křižíkova 148/34
18600 Praha 8

Reply via email to