-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatch.js
38 lines (34 loc) · 973 Bytes
/
patch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var fs = require("fs");
function patchPackageJSON() {
const packageJsonPath = "./package.json";
fs.readFile(packageJsonPath, (err, data) => {
if (err) {
console.log(err);
}
var json = JSON.parse(data);
json.browser = { fs: false, tls: false, net: false, utf8: false };
fs.writeFileSync(packageJsonPath, JSON.stringify(json));
});
}
function patchWebPackConfig() {
const webpackPath =
"node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js";
const webpackPatch = `
node: {
crypto: true,
http: true,
https: true,
stream: true,
ws: true
}`;
fs.readFile(webpackPath, (err, data) => {
if (err) {
console.log(err);
}
const dataStr = data.toString("utf8");
var replace = dataStr.replace("node: false,", webpackPatch);
fs.writeFileSync(webpackPath, replace);
});
}
patchWebPackConfig();
patchPackageJSON();