-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support preload.ts #3155
support preload.ts #3155
Conversation
lgtm, looks like it might be able to be done better though, using more out files in the original build |
Where is the original build located? Is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR! This has been a long awaited feature of the boilerplate. Here's a few minor comments.
issue that I found is webpack keep watch preload.ts after electron close in
declare global {
interface Window {
electron: {
ipcRenderer: {
myPing(): void;
on(channel: string, func: (...args: any[]): void;
once(channel: string, func: (...args: any[]): void;
};
};
};
};
export {}; |
my current solution is polling check the parent PID using webpack hook
class CheckParentPIDProcess {
interval: number;
constructor(interval: number) {
this.interval = interval;
}
check() {
try {
process.kill(parseInt(process.env.PARENT_PID), 0);
} catch (e) {
process.exit(0);
}
setTimeout(() => {
this.check();
}, this.interval);
}
apply(compiler: Compiler) {
if (!process.env.hasOwnProperty('PARENT_PID')) {
console.log('PARENT_PID not found on environment');
return;
}
compiler.hooks.entryOption.tap('CheckPIDProcess', (context, entry) => {
console.log(`Start check parent PID process: ${process.env.PARENT_PID}`);
// recommend using promise instead of setTimeout
setTimeout(() => {
this.check();
}, this.interval);
});
}
}
const configuration: webpack.Configuration = {
// ...
plugins: [
// ...
new CheckParentPIDProcess(3000),
]
} and passing process.env.PARENT_PID = process.pid.toString(); |
I rebased my fork causing this PR being closed, and then reopen this PR after pushing latest commit, now it still request changing now. Please review this, thanks. @amilajack |
@anniekatlin thanks for the contribution 🥳 this is been a long awaited feature! |
Thanks @anniekatlin |
Thanks a lot! |
closes #3058