I am trying to convert my build of a JavaSript Outlook Add-In from webpack to parceljs.
Mostly works, but fails on the configuration of the certificate for https.
The webpack configuration used an npm module called "office-addin-dev-certs" to dynamically install and use a certificate:
webpack.conf
const devCerts = require("office-addin-dev-certs");
async function getHttpsOptions() {
const httpsOptions = await devCerts.getHttpsServerOptions();
return { ca: httpsOptions.ca, key: httpsOptions.key, cert: httpsOptions.cert };
}
...
server: {
type: "https",
options: await getHttpsOptions(),
},
However parcel expects the certificate file and the key as command line parameters:
package.json:
{
"scripts": {
"dev-server": "parcel --https --cert certificate.cert --key private.key"
}
}
How can I call the async function from the node module and make the parameters dynamic?
Found a solution that works for me by copying certificate and private key to fixed file names using a node script:
install-certificate.js
Then invoking this as a "pre" script in package.json: