forked from CubikNeRubik/angular-electron-typeorm-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
postinstall.js
23 lines (18 loc) · 829 Bytes
/
postinstall.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// This script change webpack-configs for "ng serve"
const fs = require('fs');
const f_angular = 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js';
const { getConfigs } = require('./postinstall.config');
getConfigs()
.then(({electronConfig}) => {
fs.readFile(f_angular, 'utf8', function (err, data) {
if (err) {
return console.log(err);
}
var result = data.replace(/return {([\s\S]+)}[\s]+,/, 'return {');
var result = result.replace(/target: "web",/g, '');
var result = result.replace(/return \{/g, 'return {' + electronConfig);
fs.writeFile(f_angular, result, 'utf8', function (err) {
if (err) return console.log(err);
});
});
});