-
Notifications
You must be signed in to change notification settings - Fork 60
Description
Hi guys,
it took some time for me to figure out how to create a vuejs based electron app with node-irsdk support. I hope it's ok to leave a step by step guide here, even though it's not an issue. I wasn't sure where to put it else and thought maybe it's worth the write.
npm install -g @vue/cli
vue create myapp
cd into your app
vue add electron-builder
Latest version as of writing is electron 11
npm install --save https://github.com/sabifa/node-irsdk
I selected this fork, as it already fixed the import of the compiled source. If there is any better out there, let me know.
npm install --save-dev electron-rebuild
.\node-modules\.bin\electron-rebuild.cmd
This will rebuild the node-irsdk to be compatible with the electron version you selected - at least on windows.
Add a vue.config.js file to your project root with the following content
module.exports = {
pluginOptions: {
electronBuilder: {
externals: ['node-irsdk'],
nodeIntegration: true
}
}
}
This was the most crucial part to figure out - at least for me.
Now you can run your node-irsdk code in background.js as you would in every other electron app.
....
import * as irsdk from 'node-irsdk'
....
const iracing = irsdk.init({telemetryUpdateInterval: 500, sessionInfoUpdateInterval: 2000})
iracing.on('Connected', function() {
console.log('iRacing connected..')
})
iracing.on('Disconnected', function() {
console.log('iRacing disconnected..')
})
*edit: as this is way outdated and as of 30/12/2022 I couldn't get a solution with existing forks, I tried to come up with my own solution. So, if you want to give it a try, you can find it here.