diff --git a/package.json b/package.json index bbd0869d8..c02409221 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "scripts": { "ng": "npx ng", "start": "ng serve --proxy-config proxy.conf.json", - "build": "ng build --prod", - "build-ropsten": "ng build --aot", + "build": "node patch-crypto.js && ng build --prod", + "build-ropsten": "node patch-crypto.js && ng build --aot", "test": "ng test", "lint": "ng lint", "prebuild": "node version.js; npm run documentation", diff --git a/patch-crypto.js b/patch-crypto.js index ee9685b34..dc0b4e6b5 100644 --- a/patch-crypto.js +++ b/patch-crypto.js @@ -20,5 +20,18 @@ function removeComments(path) { } } +const browserConfigPath = 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js'; + +fs.readFile(browserConfigPath, 'utf8', function (err, data) { + if (err) { + return console.log(err); + } + const result = data.replace(/node: false/g, 'node: {crypto: true, stream: true}'); + + fs.writeFile(browserConfigPath, result, 'utf8', function (err) { + if (err) return console.log(err); + }); +}); + removeComments('./node_modules/crypto-js/cipher-core.js'); removeComments('./node_modules/crypto-js/core.js') \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 60c5d240a..814df3128 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,7 +18,13 @@ ], "baseUrl": "./src/", "paths": { - "@angular/*": ["../node_modules/@angular/*"] + "@angular/*": ["../node_modules/@angular/*"], + "crypto": ["./node_modules/crypto-browserify"], + "stream": ["./node_modules/stream-browserify"], + "assert": ["./node_modules/assert"], + "http": ["./node_modules/stream-http"], + "https": ["./node_modules/https-browserify"], + "os": ["./node_modules/os-browserify"], } } }