Conditional import of Electron/NodeJS libs - The app can be launch in browser mode

This commit is contained in:
Maxime GRIS
2017-05-06 00:44:59 +02:00
parent 9d43304b67
commit c434f8a8b0
9 changed files with 59 additions and 12 deletions

View File

@@ -1,6 +1,5 @@
import { Component } from '@angular/core';
import { ipcRenderer } from 'electron';
import * as childProcess from 'child_process';
import { ElectronService } from './providers/electron.service';
@Component({
selector: 'app-root',
@@ -8,10 +7,16 @@ import * as childProcess from 'child_process';
styleUrls: ['./app.component.scss']
})
export class AppComponent {
constructor() {
// Check if electron is correctly injected (see externals in webpack.config.js)
console.log('c', ipcRenderer);
// Check if nodeJs childProcess is correctly injected (see externals in webpack.config.js)
console.log('c', childProcess);
constructor(public electronService: ElectronService) {
if(electronService.isElectron()) {
console.log('Mode electron');
// Check if electron is correctly injected (see externals in webpack.config.js)
console.log('c', electronService.ipcRenderer);
// Check if nodeJs childProcess is correctly injected (see externals in webpack.config.js)
console.log('c', electronService.childProcess);
} else {
console.log('Mode web');
}
}
}