我正在尝试从gatsby默认启动程序(样板库)开始,将Electron中的GatsbyJS应用程序捆绑在一起。
使用以下代码为电子创建main.js文件后:
// Modules to control application life and create native browser window
const {app, BrowserWindow} = require('electron')
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow
function createWindow () {
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600})
// and load the index.html of the app.
mainWindow.loadFile(__dirname + '/public/index.html')
我在使用url时遇到问题,实际上它无法加载js文件,因为它们使用绝对路径:
在Electron控制台中:
Failed to load resource: net::ERR_FILE_NOT_FOUND file:///C:/app-bab7028ef226fa82b9a6.js
有什么方法可以在Electron或GatsbyJS中对其进行修复吗?