forked from yangdinglou/CS4215-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
craco.config.js
55 lines (51 loc) · 2.02 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
const cracoConfig = (module.exports = {
webpack: {
configure: webpackConfig => {
// avoid the entire process.env being inserted into the service worker
// if SW_EXCLUDE_REGEXES is unset
const definePlugin = webpackConfig.plugins.find(
plugin => plugin.constructor.name === 'DefinePlugin'
);
const inlineProcessEnv = definePlugin.definitions['process.env'];
if (!inlineProcessEnv.REACT_APP_SW_EXCLUDE_REGEXES) {
inlineProcessEnv.REACT_APP_SW_EXCLUDE_REGEXES = undefined;
}
const injectManifestPlugin = webpackConfig.plugins.find(
plugin => plugin.constructor.name === 'InjectManifest'
);
if (injectManifestPlugin) {
injectManifestPlugin.config.maximumFileSizeToCacheInBytes = 10 * 1024 * 1024;
}
// add rules to pack WASM (for Sourceror)
// adapted from https://prestonrichey.com/blog/react-rust-wasm/
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);
}
});
});
webpackConfig.output.webassemblyModuleFilename = 'static/[hash].module.wasm';
// workaround .mjs files by Acorn
webpackConfig.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto'
});
return webpackConfig;
}
},
jest: {
configure: jestConfig => {
jestConfig.transformIgnorePatterns = [
'[/\\\\]node_modules[/\\\\](?!(@ion-phaser[/\\\\]react[/\\\\])|(js-slang[/\\\\])|(array-move[/\\\\])|(konva[/\\\\.*])|(react-konva[/\\\\.*])).*\\.(js|jsx|ts|tsx)$',
'^.+\\.module\\.(css|sass|scss)$'
];
jestConfig.moduleNameMapper['ace-builds'] = '<rootDir>/node_modules/ace-builds';
return jestConfig;
}
}
});