Conditional import of Electron/NodeJS libs - The app can be launch in browser mode
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user