File Structure Questions


#1

Hey!

I’ve just today discovered Electron, the “Getting Started” tutorial on the GitHub page said that the 3 files (index.html, package.son and main.js) should be in the root/app folder.

But where do i put my apps own node/javascript, can i make a JS folder without loosing privileges or something like that?

And things like adding menus, and changing the window properties should that be in main.js (noticed i couldn’t use console.log() in main.js, at least the development tools didn’t show it)?

Dazing


#2

You can include a script in your index.html via a <script> tag. From there it’s just node in the browser :smile:

Your filetree could be like this:

- index.html
- package.json
- main.js
- js/
  - app.js
  - some-module.js
- css/
  - style.css

Then in index.html:

<html>
<head>
  <link rel="stylesheet" href="./css/style.css">
  <script src="./js/app.js"></script>
</head>
...

and in app.js:

someModule = require('./some-module.js');

// your application logic

#3

To do menus and other OS related stuff from the renderer you can use the remote module