Loading

vue-cli-plugin-electron-builder preload build 无法加载问题

记录下:build preload 加载失败的解决方法

background.js中的配置,preload (打包的话)必须写成 path.join(__dirname, '/preload.js'),否则不能识别路径。
如果配置为本地的perload文件位置,会造成打包无法识别preload 的问题


  const win = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      // Use pluginOptions.nodeIntegration, leave this alone
      // See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
      nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION,
      contextIsolation: !process.env.ELECTRON_NODE_INTEGRATION,
      preload: path.join(__dirname, '/preload.js')
    },
  });

posted @ 2022-01-29 19:22  ZJH_BLOGS  阅读(869)  评论(0编辑  收藏  举报