electron-node-red
electron-node-red copied to clipboard
Loading extra resources for application
Hello, at start I would like to thank you for developing this template.
I'm trying to make my first app that will work on a computer without internet access, however to draw graph i use node-red-node-ui-vega which unfortunately fetches data from CDN.
Fortunately in Node-RED if a module has a directory called resources at the top level, the runtime will make anything in that directory available to the editor under the url /resources/
Same problem here.
I also have tried to load resources with httpStatic attribute in main.js. Without success. When I start by yarn I get error message.
My solution: Change line 60 of main.js to red_app.use("/",express.static(__dirname +"/resources"));
Hello,
thanks for the idea goodartmr.
I put the files downloaded from the CDN in a folder called "external" in the main directory and in main.js I make the following change:
red_app.use('/external', express.static(path.join(__dirname, 'external')))
In addition, to package the application, you need to add a fragment in the package.json file
"files": [
<...>
{
"from": "external",
"to": "node_modules/@node-red/external"
}
]
as a result, the resources should be available as below:
loadScripts(["/external/node-red-node-ui-vega/vega-cdn.js",
"/external/node-red-node-ui-vega/vega-lite-cdn.js",
"/external/node-red-node-ui-vega/vega-embed-cdn.js"],