Skip to content

Commit

Permalink
Allow Angular Using Electron Modules
Browse files Browse the repository at this point in the history
  • Loading branch information
flowfire committed Jun 26, 2018
1 parent 1d48e32 commit ec705ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"main": "main.js",
"private": true,
"scripts": {
"postinstall": "npx electron-builder install-app-deps",
"postinstall": "npx electron-builder install-app-deps && node postinstall",
"ng": "ng",
"start": "npm-run-all -p ng:serve electron:serve",
"build": "npm run electron:tsc && ng build",
Expand Down
15 changes: 15 additions & 0 deletions postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Allow angular using electron module (native node modules)
const fs = require('fs');
const f_angular = 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js';

fs.readFile(f_angular, 'utf8', function (err, data) {
if (err) {
return console.log(err);
}
var result = data.replace(/target: "electron-renderer",/g, '');
var result = result.replace(/return \{/g, 'return {target: "electron-renderer",');

fs.writeFile(f_angular, result, 'utf8', function (err) {
if (err) return console.log(err);
});
});

0 comments on commit ec705ee

Please sign in to comment.