Skip to content

Commit 3a42ff9

Browse files
authored
Provide empty Node mocks for fs, net, tls (#672)
1 parent cc4aa7b commit 3a42ff9

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

config/webpack.config.dev.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,5 +203,12 @@ module.exports = {
203203
// makes the discovery automatic so you don't have to restart.
204204
// See https://github.com/facebookincubator/create-react-app/issues/186
205205
new WatchMissingNodeModulesPlugin(paths.appNodeModules)
206-
]
206+
],
207+
// Some libraries import Node modules but don't use them in the browser.
208+
// Tell Webpack to provide empty mocks for them so importing them works.
209+
node: {
210+
fs: 'empty',
211+
net: 'empty',
212+
tls: 'empty'
213+
}
207214
};

config/webpack.config.prod.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,5 +238,12 @@ module.exports = {
238238
}),
239239
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
240240
new ExtractTextPlugin('static/css/[name].[contenthash:8].css')
241-
]
241+
],
242+
// Some libraries import Node modules but don't use them in the browser.
243+
// Tell Webpack to provide empty mocks for them so importing them works.
244+
node: {
245+
fs: 'empty',
246+
net: 'empty',
247+
tls: 'empty'
248+
}
242249
};

0 commit comments

Comments
 (0)