Skip to content

Commit

Permalink
Support simple electron support via TARGET_ELECTRON env variable
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Mahon <[email protected]>
  • Loading branch information
danielmahon committed Jul 5, 2019
1 parent e50e795 commit c020acb
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions packages/react-scripts/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,16 +663,20 @@ module.exports = function(webpackEnv) {
].filter(Boolean),
// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.
node: {
module: 'empty',
dgram: 'empty',
dns: 'mock',
fs: 'empty',
http2: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty',
},
node: process.env.TARGET_ELECTRON
? undefined
: {
module: 'empty',
dgram: 'empty',
dns: 'mock',
fs: 'empty',
http2: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty',
},
// Support electron-renderer target via environmental flag, default to web
target: process.env.TARGET_ELECTRON ? 'electron-renderer' : 'web',
// Turn off performance processing because we utilize
// our own hints via the FileSizeReporter
performance: false,
Expand Down

0 comments on commit c020acb

Please sign in to comment.