Integrates Svelte into Node-RED so that the editor-part of a node can be developed using Svelte templates.
npm install -g svelte-integration-red`
Then you can run the build-process with the command `sir` in your project's main directory. SIR will analyze your `package.json` and check if it finds a `.svelte` template and a `.doc.html` for any node mentioned within. It then compiles these to HTML files that comply with Node-RED's HTML file format. If your node is not in the same directory than your package.json you can also submit the path to it's folder as a command line parameter (like the test-node example below).
Compile single files with `sir myNodeName.svelte`
The html file will automatically be minified. If you need a more readable version for debugging purposes use `sir -m=false`.
Usage
$3
Creating a Node-RED node with SIR is mostly similiar to a normal Node-RED node.
Register your node in the package.json
`
{
"name": "my-node",
"version": "0.0.1",
"description": "My awesome node",
"node-red": {
"nodes": {
"my-node-name": "my-node-name.js",
}
}
}
`
Create a .js file with the following code:
`
module.exports = function (RED) {
function MyNodeName (config) {
RED.nodes.createNode(this, config)
const node = this
node.name = config.name
}
RED.nodes.registerType('my-node-name', MyNodeName)
}
`
And instead of the .html file, which will be created later by SIR you need a .svelte file.
Attention: The Node-RED part must be stated in