我有一个应用程序,有单独的ExpressJS后端和单独的超文本标记语言前端。
我的ExpressJS后端位于root/scripts/server.js
中
我的HTML前端位于root/index.html
中。这个前端使用的是javascript逻辑,它是从webpack
生成的,并且工作正常。
为了让这个项目正常工作,我首先使用以下命令启动我的ExpressJS后端:
babel-node ./scripts/server.js --presets es2015,stage-0
然后我打开我的index.html
,一切都很正常。
现在,我想使用ElectronJS将后端和前端打包到一个桌面应用程序中。
我的项目有在桌面模式下启动电子应用程序的main.js
脚本。它位于root/main.js
中。它有以下代码:
const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
const path = require('path')
const url = require('url')
let mainWindow
function createWindow () {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true,
useContentSize: true,
resizable: false
})
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))
mainWindow.webContents.openDevTools()
mainWindow.on('closed', function () {
mainWindow = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
if (mainWindow === null) {
createWindow()
}
})
这个脚本启动only my HTML front。我需要添加什么,以便与HTML前端打包Express后端?
发布于 2017-02-22 05:03:00
尝试将如下内容添加到main.js中:
const server = require('./scripts/server');
https://stackoverflow.com/questions/42374989
复制相似问题