According to the tutorial, there are two parts of an electron app - the entry main.js
file and index.html
.
main.js
as a script in the html fileYou are mixing up a couple of things.
main.js
is the first file called when your run your application. Before everything else. It does not run any front-end code.
Usually, in it, you create with the BrowserWindow
API a chromium window, then load an .html file in it. (index.html
for example).
Then, your index.html
, you can call for every front JS code you want, or CSS or whatever. For example you can add there a <script src="myapp.js"></script>
, which will run front-end code.
It is important to understand the difference between the main process (back-end) and the render process (front-end).
See the quick start guide that explains that very well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With