Skip to content

Commit

Permalink
fix(demo): fix demo webpack config
Browse files Browse the repository at this point in the history
  • Loading branch information
chongqiangchen committed Apr 18, 2023
1 parent ff69aca commit ac7ac54
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions apps/demo/craco.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const cracoAlias = require("craco-alias");
const nodeExternals = require('webpack-node-externals');
const webpack = require("webpack");

module.exports = {
style: {
Expand All @@ -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;
}
}
Expand Down

0 comments on commit ac7ac54

Please sign in to comment.