Skip to content

Commit

Permalink
simplify buildconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
SamDelaney committed Dec 10, 2024
1 parent fb1ef44 commit f1c2b4f
Showing 1 changed file with 10 additions and 55 deletions.
65 changes: 10 additions & 55 deletions craco.buildconfig.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,12 @@
const webpack = require('webpack');
const craco_config = require('./craco.config')
const webpack_config = craco_config.webpack.configure

module.exports = {
...exports,
webpack: {
configure: (webpackConfig) => {
const wasmExtensionRegExp = /\.wasm$/;
webpackConfig.resolve.extensions.push('.wasm');
webpackConfig.experiments = {
asyncWebAssembly: true,
lazyCompilation: true,
syncWebAssembly: true,
topLevelAwait: true,
};
webpackConfig.resolve.fallback = {
...webpackConfig.resolve.fallback,
fs: false, // fs is not typically available in the browser
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
util: require.resolve('util'),
os: require.resolve('os-browserify/browser'),
path: require.resolve('path-browserify'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
net: false, // net is not typically available in the browser
tls: false, // tls is not typically available in the browser
dns: require.resolve('dns.js'),
zlib: require.resolve('browserify-zlib'),
url: require.resolve('url'),
buffer: require.resolve('buffer/'),
assert: require.resolve('assert/'),
dgram: false, // dgram is not typically available in the browser
process: require.resolve('process'),
};
webpackConfig.module.rules.forEach((rule) => {
(rule.oneOf || []).forEach((oneOf) => {
if (oneOf.type === 'asset/resource') {
oneOf.exclude.push(wasmExtensionRegExp);
}
});
});
webpackConfig.plugins.push(
new webpack.ProvidePlugin({
process: 'process',
Buffer: ['buffer', 'Buffer'],
}),
let config = webpack_config(webpackConfig);
config.plugins.push(
{
apply: (compiler) => {
compiler.hooks.done.tap('DonePlugin', (stats) => {
Expand All @@ -52,17 +16,8 @@ module.exports = {
});
});
}
}
);

return webpackConfig;
},
},
jest: {
configure: {
globals: {
CONFIG: true,
},
},
},
};
})
return config;
}
}
}

0 comments on commit f1c2b4f

Please sign in to comment.