1

I am trying to set up an Angular2 CLI project in electron and am not quite sure where to start after getting the basic Angular piece generated by the CLI set up.

I have used Angular2 with electron successfully before, but that was not with the CLI piece.

So, for clarification, I have generated the basic Angular2 App using the Angular2 CLI. Now I am unsure of how to wire it up with Electron.

Has anyone done this before? Maybe you could provide some insight. Any tidbits of help will be greatly appreciated.

Thanks!

1 Answers1

4

just figured I'd let you all know the solution I found. Turns out when you do an ng-build using the CLI it is completely dropping the dist folder and then remakes it using the src folder. This means it gets rid of the main.js, renderer.js, and package.json electron needs which are stored in the dist folder.

In order to ensure the Electron files (main.js, package.json, and renderer.js) get carried over to the Dist folder each time I use ng build, I set up a task using GulpJS to copy them to the correct location. Anyways, hope this helps anyone facing the same issue!

  • Hey I am trying to do exactly this as well! Are you accessing the site through the hosted URL provided by Angular CLI - `win.loadURL("http://localhost:4200/")` – Luca Oct 09 '16 at 07:48
  • No, in the main.js file that Electron uses, the function that creates the window is where the URL is specified. mainWindow.loadURL(`file://${__dirname}/index.html`) With Electron, the site/application is run through a stripped down browser running Chromium. There is no URL bar, no toolbar, etc... – Sabin Adams Oct 10 '16 at 15:47
  • Yeah I understand that but for local development how are you getting live reload if you aren't pointing to localhost using angular CLI. I pointed to my dist folder and its just a stale version of my app unless I rebuild via `ng build` – Luca Oct 11 '16 at 01:13