We use ReactJs to build our app, when using React Offical build code, it returns a build stcuture like this:
The guide says you can drop the files in the build folder to any static server and it will work.
I did this to a Express 4.x app, it really works.
But when I did this to Electron app, it failed. Because when index.html and static folder are in the electron root folder, inside the index.html, it refers js or css file using directory like this:
In this way, Electron will try to look for the js file in following path and get no file found error, like this:
I have tried manully change the script src from “/static/js/xx.js” to “./static/js/xx.js” and “static/js/xx.js” (Please pay attention to the start of the src). Both work perfectly in Electron.
We really don’t want to touch the build process in order to avoid unneccessary potential problems.
My question is, how can I make Electron look for static files in certain folder like Express does. Or, is there anyway to make electron work leaving the default src unchanged?