From ac7ac5485b906695e6b1c26fd4b1576c46b2e9ec Mon Sep 17 00:00:00 2001 From: chenchongqiang Date: Tue, 18 Apr 2023 09:37:24 +0800 Subject: [PATCH] fix(demo): fix demo webpack config --- apps/demo/craco.config.js | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/apps/demo/craco.config.js b/apps/demo/craco.config.js index dcf61ea..b2ef58d 100644 --- a/apps/demo/craco.config.js +++ b/apps/demo/craco.config.js @@ -1,5 +1,5 @@ const cracoAlias = require("craco-alias"); -const nodeExternals = require('webpack-node-externals'); +const webpack = require("webpack"); module.exports = { style: { @@ -21,8 +21,34 @@ module.exports = { ], webpack: { configure: (webpackConfig, { env, paths }) => { - webpackConfig.externalsPresets = {node: true}; - webpackConfig.externals = [nodeExternals()]; + // eslint-disable-next-line no-param-reassign + webpackConfig.resolve.fallback = { + "http": require.resolve("stream-http"), + "https": require.resolve("https-browserify"), + "zlib": require.resolve("browserify-zlib"), + "stream": require.resolve("stream-browserify"), + "events": require.resolve("events/"), + "crypto": require.resolve("crypto-browserify"), + "assert": require.resolve("assert/"), + "buffer": require.resolve("buffer/"), + "util": require.resolve("util/"), + "path": require.resolve("path-browserify"), + "tty": require.resolve("tty-browserify"), + "os": require.resolve("os-browserify/browser"), + "punycode": require.resolve("punycode/"), + "fs": false, + "url": require.resolve("url/"), + "net": require.resolve("net-browserify"), + "child_process": false, + async_hooks: false, + rawBody: false, + }; + + webpackConfig.plugins.push( + new webpack.ProvidePlugin({ + Buffer: ["buffer", "Buffer"] + }) + ); return webpackConfig; } }