Ok - so here is how you can take full advantage of the pre-compile steps from DuetWebControl (skip ahead if you don't have a complex plugin):
git clone https://github.com/Duet3D/DuetWebControl.git
cd DuetWebControl
git checkout v3.3-dev
npm install
Then call a heart and blood pressure specialist doctor due to:
25 vulnerabilities (13 moderate, 12 high)
and tons of this library is no longer supported
messages...
Then add the following snippet to the big plugin array/list at the bottom of src/plugins/index.js
to include your new plugin:
new DwcPlugin({
id: 'MyNewPluginID',
name: 'My-New-Plugin',
author: 'Thomas Kriechbaumer',
version,
loadDwcResources: () => import(
/* webpackChunkName: "MyNewPluginID" */
'./MyNewPluginID/index.js'
)
}),
Then continue with:
# still in the root dir of DuetWebControl repo
cd src/plugins/
mkdir MyNewPluginID
cd MyNewPluginID
echo 'console.log("Hello World!");' > index.js
npm run build
This will create 4 new files with MyNewPluginID.123abc.<different-extensions>
under dist/js/
. Copy those into your plugin ZIP file under dwc/js/
.
And essentially all this can be shortened by directly doing this:
Create a ZIP file with these files:
MyNewPluginID.zip
- plugin.json
- dwc/
- js/
- MyNewPluginID.js
With plugin.json
being this:
{
"id": "MyNewPluginID",
"name": "My-New-Plugin",
"author": "Thomas Kriechbaumer",
"version": "1.0.0",
"license": "MIT",
"homepage": "http://example.com",
}
(observe that I did not mention dwcFiles
- it will figure itself out that there is a .js file to copy into the right place.
With MyNewPluginID.js
being this:
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([
["MyNewPluginID"], {
"./src/plugins/MyNewPluginID/index.js": function (e, t, n) {
"use strict";
console.log("Hello World");
// YOUR CODE HERE!
}
}
]);
Not sure if this is the best way to build new plugins, but it worked for me.