抛出的错误:
Error: Cannot find module 'D:xxx
esourcesset_pac.node'
at webpackEmptyContext (webpack:///./src/main/modules_sync?:2:10)
at eval (webpack:///./src/main/modules/proxyConfig.js?:23:70)
at Module../src/main/modules/proxyConfig.js (D:xxxdistelectronmain.js:801:1)
at __webpack_require__ (D:xxxdistelectronmain.js:21:30)
at eval (webpack:///./src/main/index.js?:6:78)
at Module../src/main/index.js (D:xxxdistelectronmain.js:766:1)
at __webpack_require__ (D:xxxdistelectronmain.js:21:30)
at eval (webpack:///./src/main/index.dev.js?:11:1)
at Object../src/main/index.dev.js (D:xxxdistelectronmain.js:754:1)
at __webpack_require__ (D:xxxdistelectronmain.js:21:30)
解决方案
const setpac_path = path.join(process.cwd(), '/resources/set_pac.node');
log.info('pac_path', setpac_path);
const requireFunc = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
const setPac = requireFunc(setpac_path);
https://stackoverflow.com/questions/42797313/webpack-dynamic-module-loader-by-require/53074814#53074814
https://github.com/webpack/webpack/issues/4175#issuecomment-342931035