我有一个create-react-app,我正在努力弄清楚如何让electron-packager使用产品构建来创建一个.exe。它一直在使用./src中的开发文件夹。
正在运行
electron-packager . --no-prune --ignore=/node_modules --ignore=/e2e --overwrite --ignore=/src
不起作用。我也试过
electron-packager ./build --no-prune --ignore=/node_modules --ignore=/e2e --overwrite --ignore=/src
以下是我的package.json中的相关条目
{
"homepage": "./",
"main": "src/electron-entry.js",
"build": {
"target": "nsis",
"dir": "./build"
}
}下面是我的loadURL,它指向生产构建。在electron-entry.js中。当我在dev环境中运行时,这是可行的。
new BrowserWindow(BrowserWindowProps).loadURL(url.format({
pathname: path.join(__dirname, '/../build/index.html'),
protocol: 'file:',
slashes: true
}));electron-entry.js中的数据是否与electron-packager使用的目录相关?
发布于 2018-04-12 19:02:50
找到了解决办法。我将我的电子条目文件放在根目录中,并更改了loadURL以反映这一点。
let startUrl = process.env.ELECTRON_START_URL || url.format({
pathname: path.join(__dirname, '/build/index.html'),
protocol: 'file:',
slashes: true
});
mainWindow.loadURL(startUrl);更改了我的package.json以反映此更改:
{
"main": "./electron-entry.js",
}然后我跑了
electron-packager . --no-prune --ignore=/node_modules --ignore=/e2e --overwrite --ignore=/src
https://stackoverflow.com/questions/49762251
复制相似问题