forked from nanaknihal/whoisthis.wtf-frontend
-
Notifications
You must be signed in to change notification settings - Fork 1
/
craco.config.js
64 lines (57 loc) · 2.27 KB
/
craco.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const path = require('path');
const { when, whenDev, whenProd, whenTest, ESLINT_MODES, POSTCSS_MODES } = require("@craco/craco");
module.exports = {
reactScriptsVersion: "react-scripts" /* (default value) */,
babel: {
presets: [],
plugins: [],
// loaderOptions: { /* Any babel-loader configuration options: https://github.com/babel/babel-loader. */ },
// loaderOptions: (babelLoaderOptions, { env, paths }) => { return babelLoaderOptions; }
},
webpack: {
// configure: { /* Any webpack configuration options: https://webpack.js.org/configuration */ },
configure: (webpackConfig, { env, paths }) => {
webpackConfig.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: "javascript/auto"
});
const wasmExtensionRegExp = /\.wasm$/;
webpackConfig.resolve.extensions.push('.wasm');
webpackConfig.module.rules.forEach(rule => {
(rule.oneOf || []).forEach(oneOf => {
if (oneOf.loader && oneOf.loader.indexOf('file-loader') >= 0) {
// make file-loader ignore WASM files
oneOf.exclude.push(wasmExtensionRegExp);
}
});
});
// add a dedicated loader for WASM
webpackConfig.module.rules.push({
test: wasmExtensionRegExp,
include: path.resolve(__dirname, 'src'),
use: [{ loader: require.resolve('wasm-loader'), options: {} }]
});
// // Add web assembly support
// if (webpackConfig.module.experiments) {
// webpackConfig.module.experiments.push({
// asyncWebAssembly: true,
// });
// } else {
// webpackConfig.module.experiments= {
// asyncWebAssembly: true,
// };
// }
return webpackConfig;
}
},
plugins: [
{
plugin: {
overrideCracoConfig: ({ cracoConfig, pluginOptions, context: { env, paths } }) => { return cracoConfig; },
overrideWebpackConfig: ({ webpackConfig, cracoConfig, pluginOptions, context: { env, paths } }) => { return webpackConfig; },
},
options: {}
}
]
};