Use react-app-rewired to enable native Node/electron modules

This commit is contained in:
Tiago Koji Castro Shibata 2018-08-03 15:29:37 -07:00
Родитель be1237623c
Коммит 532cdcb7c5
3 изменённых файлов: 35 добавлений и 3 удалений

Просмотреть файл

@ -0,0 +1,16 @@
module.exports = function override(config, env) {
// __filename and __dirname are currently mocked
config.node = {
Buffer: false,
child_process: false,
dgram: false,
fs: false,
global: false,
net: false,
process: false,
setImmediate: false,
tls: false,
};
config.target = 'electron-renderer';
return config;
}

Просмотреть файл

@ -24,8 +24,9 @@
"eject": "react-scripts-ts eject",
"postinstall": "node scripts/postinstall.js && yarn copy-netron",
"copy-netron": "yarn --cwd deps/Netron && python deps/copy_netron.py",
"build-electron": "react-app-rewired build --scripts-version react-scripts-ts",
"electron-dev": "electron . http://localhost:3000",
"electron-prod": "yarn build && electron ."
"electron-prod": "yarn build-electron && electron ."
},
"build": {
"appId": "com.microsoft.dashboard.winml",
@ -45,8 +46,10 @@
"@types/react": "^16.4.7",
"@types/react-dom": "^16.0.6",
"@types/react-redux": "^6.0.5",
"@types/unzipper": "^0.8.4",
"babel-minify": "^0.4.3",
"electron": "^2.0.6",
"react-app-rewired": "^1.5.2",
"react-scripts-ts": "^2.16.0",
"typescript": "^2.9.2"
}

Просмотреть файл

@ -158,6 +158,12 @@
dependencies:
csstype "^2.2.0"
"@types/unzipper@^0.8.4":
version "0.8.4"
resolved "https://registry.yarnpkg.com/@types/unzipper/-/unzipper-0.8.4.tgz#0665b064763472c5e68cb10620fc2ce36b4587e7"
dependencies:
"@types/node" "*"
"@uifabric/icons@>=6.0.2 <7.0.0":
version "6.0.2"
resolved "https://registry.yarnpkg.com/@uifabric/icons/-/icons-6.0.2.tgz#743ed18028285e2c6498b3f15b2195581255cafb"
@ -2103,7 +2109,7 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4:
safe-buffer "^5.0.1"
sha.js "^2.4.8"
cross-spawn@5.1.0, cross-spawn@^5.0.1:
cross-spawn@5.1.0, cross-spawn@^5.0.1, cross-spawn@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
dependencies:
@ -2513,7 +2519,7 @@ dotenv-expand@4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/dotenv-expand/-/dotenv-expand-4.2.0.tgz#def1f1ca5d6059d24a766e587942c21106ce1275"
dotenv@4.0.0:
dotenv@4.0.0, dotenv@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-4.0.0.tgz#864ef1379aced55ce6f95debecdce179f7a0cd1d"
@ -6159,6 +6165,13 @@ rc@^1.0.1, rc@^1.1.2, rc@^1.1.6, rc@^1.2.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"
react-app-rewired@^1.5.2:
version "1.5.2"
resolved "https://registry.yarnpkg.com/react-app-rewired/-/react-app-rewired-1.5.2.tgz#0f5cdbc92f47f166bb0bcadf8a5d00999b90f68f"
dependencies:
cross-spawn "^5.1.0"
dotenv "^4.0.0"
react-dev-utils@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/react-dev-utils/-/react-dev-utils-5.0.1.tgz#1f396e161fe44b595db1b186a40067289bf06613"