Skip to content

Commit f1c2b4f

Browse files
committed
simplify buildconfig
1 parent fb1ef44 commit f1c2b4f

File tree

1 file changed

+10
-55
lines changed

1 file changed

+10
-55
lines changed

craco.buildconfig.js

+10-55
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,12 @@
1-
const webpack = require('webpack');
1+
const craco_config = require('./craco.config')
2+
const webpack_config = craco_config.webpack.configure
23

34
module.exports = {
5+
...exports,
46
webpack: {
57
configure: (webpackConfig) => {
6-
const wasmExtensionRegExp = /\.wasm$/;
7-
webpackConfig.resolve.extensions.push('.wasm');
8-
webpackConfig.experiments = {
9-
asyncWebAssembly: true,
10-
lazyCompilation: true,
11-
syncWebAssembly: true,
12-
topLevelAwait: true,
13-
};
14-
webpackConfig.resolve.fallback = {
15-
...webpackConfig.resolve.fallback,
16-
fs: false, // fs is not typically available in the browser
17-
crypto: require.resolve('crypto-browserify'),
18-
stream: require.resolve('stream-browserify'),
19-
util: require.resolve('util'),
20-
os: require.resolve('os-browserify/browser'),
21-
path: require.resolve('path-browserify'),
22-
http: require.resolve('stream-http'),
23-
https: require.resolve('https-browserify'),
24-
net: false, // net is not typically available in the browser
25-
tls: false, // tls is not typically available in the browser
26-
dns: require.resolve('dns.js'),
27-
zlib: require.resolve('browserify-zlib'),
28-
url: require.resolve('url'),
29-
buffer: require.resolve('buffer/'),
30-
assert: require.resolve('assert/'),
31-
dgram: false, // dgram is not typically available in the browser
32-
process: require.resolve('process'),
33-
};
34-
webpackConfig.module.rules.forEach((rule) => {
35-
(rule.oneOf || []).forEach((oneOf) => {
36-
if (oneOf.type === 'asset/resource') {
37-
oneOf.exclude.push(wasmExtensionRegExp);
38-
}
39-
});
40-
});
41-
webpackConfig.plugins.push(
42-
new webpack.ProvidePlugin({
43-
process: 'process',
44-
Buffer: ['buffer', 'Buffer'],
45-
}),
8+
let config = webpack_config(webpackConfig);
9+
config.plugins.push(
4610
{
4711
apply: (compiler) => {
4812
compiler.hooks.done.tap('DonePlugin', (stats) => {
@@ -52,17 +16,8 @@ module.exports = {
5216
});
5317
});
5418
}
55-
}
56-
);
57-
58-
return webpackConfig;
59-
},
60-
},
61-
jest: {
62-
configure: {
63-
globals: {
64-
CONFIG: true,
65-
},
66-
},
67-
},
68-
};
19+
})
20+
return config;
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)