使用电子和角度热装 [英] Hot reload using Electron and Angular
问题描述
我正在为我的应用程序使用Angular和Electron.
我正在寻找一种启用热重装的方法...
运行yarn run electron
(脚本:"electron": "ng build --base-href ./ && electron ."
)时,如果保存更改,则不会重新加载我的应用程序.
这是我的main.js文件:
I'm using Angular and Electron for my app.
I'm looking for a way to enable hot reload...
When I run my yarn run electron
(scripts : "electron": "ng build --base-href ./ && electron ."
), if I save a change, my app isn't reloading.
Here is my main.js file :
const { app, BrowserWindow } = require("electron");
const path = require("path");
const url = require("url");
let win;
function createWindow() {
win = new BrowserWindow({ width: 800, height: 600 });
// load the dist folder from Angular
win.loadURL(
url.format({
pathname: path.join(__dirname, `/dist/index.html`),
protocol: "file:",
slashes: true
})
);
// The following is optional and will open the DevTools:
// win.webContents.openDevTools()
win.on("closed", () => {
win = null;
});
}
app.on("ready", createWindow);
// on macOS, closing the window doesn't quit the app
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
// initialize the app's main window
app.on("activate", () => {
if (win === null) {
createWindow();
}
});
我试图将require('electron-reload')(__dirname);
包含在main.js文件中,但未做任何更改
I tried to include require('electron-reload')(__dirname);
in the main.js file but nothing changed
推荐答案
我发现了这个问题: https://github.com/maximegris/angular-electron
它是一个空的项目模板,使用了Electron和Angular.
执行yarn start
允许热重装.
它写在README.md中!
I found this : https://github.com/maximegris/angular-electron
It's an empty project template, using Electron and Angular.
Execute yarn start
allow the hot reloading.
It's well written in the README.md !
这篇关于使用电子和角度热装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!