webpack打包含dll的electron项目配置
作者:互联网
electron 调用 dll ,webpack的配置
//重点配置项
module.exports = {
output: {
libraryTarget: 'commonjs2',
},
//预加载 node electron
externalsPresets: {
node: true,
electron: true,
electronRenderer: true,
electronMain: true
},
//外部模块
externals: ['ffi-napi', 'ref-napi', 'ref-array-napi', 'ref-struct-napi'],
}
特别说明
webpack打包模块中__dirname获取不到怎么办? 改用 process.cwd()。
//render.js
const path = require('path');
const ffi = require('ffi-napi');
const ref = require('ref-napi');
//dll路径
let libpath = path.join(process.cwd(), '/native/ControlCAN.dll');
//加载dll
let testLib = ffi.Library(libpath, {
VCI_OpenDevice: ['UInt32', ['UInt32', 'UInt32', 'UInt32']]
});
参考网址:
https://blog.csdn.net/zxl761303248/article/details/108051680
标签:true,webpack,dll,electron,ffi,ref,napi 来源: https://blog.csdn.net/weixin_42809461/article/details/113694237