electron-react-boilerplate icon indicating copy to clipboard operation
electron-react-boilerplate copied to clipboard

Create multiple Windows

Open ZGKtob opened this issue 2 years ago • 10 comments

How to do create multiple Windows

ZGKtob avatar Jun 29 '22 10:06 ZGKtob

At a minimum, you'll need a second call to new BrowserWindow({...}) in your main process. You might also want different html template entry points.

If you want to load a different html template for the second window, you'll need another new HtmlWebpackPlugin({...}) entry in the various webpack configs.

cinderblock avatar Jul 01 '22 01:07 cinderblock

HtmlWebpackPlugin

我配置了但是加载的是同一个html文件

ZGKtob avatar Jul 01 '22 01:07 ZGKtob

I configured but the same html file is loaded

Did you see the .loadURL(...) line in the example?

cinderblock avatar Jul 01 '22 02:07 cinderblock

企业微信截图_16566554008018 kanl 企业微信截图_16566554262746 企业微信截图_16566554533770 看了的

ZGKtob avatar Jul 01 '22 06:07 ZGKtob

渲染的时候还是调用的renderjs来进行渲染的

ZGKtob avatar Jul 01 '22 06:07 ZGKtob

我用路由的形式去,在开发环境下可以但是在生产环境下就不行了

ZGKtob avatar Jul 01 '22 06:07 ZGKtob

HtmlWebpackPlugin automatically inserts a script tag for the Webpack "entry". You're getting into some slightly more advanced usage of HtmlWebpackPlugin.

I think you'll need to add a second entry for webpack and then configure the different HtmlWebpackPlugin instances to use one or the other. I think that's what the chunks array is for.

cinderblock avatar Jul 02 '22 01:07 cinderblock

这个entry 我配置了第二个 但是输出的文件都只有这一个呀 我在webpack.config.render.dev.ts 中配置了 也在 webpack.config.render.prod.ts中也配置了 但是输出的文件都只有render.js

ZGKtob avatar Jul 04 '22 01:07 ZGKtob

生产环境是file协议,可能要用hash路由或者用query来区分渲染不同的页面

我用路由的形式去,在开发环境下可以但是在生产环境下就不行了

1zilc avatar Jul 05 '22 08:07 1zilc

Anyone stuck here pls contact me

DVGY avatar Oct 31 '22 00:10 DVGY

I wrote a guide based on this issue https://medium.com/@alielmajdaoui/multiple-windows-in-electron-react-boilerplate-c6d763f38306

alielmajdaoui avatar Nov 04 '22 22:11 alielmajdaoui

@alielmajdaoui Nice, even I wrote a blog. https://dvgy.hashnode.dev/how-to-make-multi-window-electron-application

DVGY avatar Nov 06 '22 09:11 DVGY

@alielmajdaoui Nice, even I wrote a blog. https://dvgy.hashnode.dev/how-to-make-multi-window-electron-application

thank you for tutorial but its not working when i build production, can u fix it pls ?

emptydn1 avatar Jan 11 '23 04:01 emptydn1

@emptydn1 you will need to edit the webpack prod file. I will try to document that in the same article I wrote if I got time this week.

alielmajdaoui avatar Jan 11 '23 13:01 alielmajdaoui

I will try to document that in the same articl

@emptydn1 you need to copy paste the same config in webpack prod files

DVGY avatar Jan 12 '23 09:01 DVGY

Closing because this seems resolved

amilajack avatar Feb 05 '23 20:02 amilajack

@alielmajdaoui how about prod file, do u have time to write it?

EricProcessor avatar Nov 21 '23 07:11 EricProcessor

@EricProcessor it's already updated

alielmajdaoui avatar Feb 04 '24 09:02 alielmajdaoui