-
Notifications
You must be signed in to change notification settings - Fork 494
/
craco.config.js
79 lines (75 loc) · 2.09 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const { whenDev } = require("@craco/craco");
const CracoAlias = require("craco-alias");
const CracoSwcPlugin = require("craco-swc");
module.exports = {
plugins: [
{
plugin: CracoAlias,
options: {
source: "tsconfig",
baseUrl: "./src",
tsConfigPath: "./tsconfig.extend.json",
},
},
// Use Babel on dev since Jotai doesn’t have swc plugins yet
// See https://github.com/pmndrs/jotai/discussions/1057
// Use swc on production and test since Babel seems to break Jest
...whenDev(
() => [],
[
{
plugin: CracoSwcPlugin,
options: {
swcLoaderOptions: {
jsc: {
target: "es2021",
transform: {
react: {
runtime: "automatic",
},
},
},
},
},
},
]
),
],
babel: {
plugins: [
"jotai/babel/plugin-debug-label",
"./node_modules/jotai/babel/plugin-react-refresh",
],
},
jest: {
configure: (jestConfig) => {
jestConfig.setupFilesAfterEnv = ["./src/test/setupTests.ts"];
jestConfig.forceExit = true; // jest hangs if we don't have this
jestConfig.moduleNameMapper["lodash-es"] = "lodash";
jestConfig.moduleNameMapper["^.+\\.(css|less)$"] =
"<rootDir>/src/test/importStub.js";
jestConfig.moduleNameMapper["^!!raw-loader!.*"] =
"<rootDir>/src/test/importStub.js";
jestConfig.extensionsToTreatAsEsm = [".ts", ".tsx"];
// Need to transform node modules to prevent
// "cannot use import outside module" error
jestConfig.transformIgnorePatterns = [
// "/node_modules/",
"\\.pnp\\.[^\\/]+$",
];
return jestConfig;
},
},
webpack: {
configure: {
resolve: {
// Polyfill for monaco-editor-auto-typings
fallback: {
path: require.resolve("path-browserify"),
// stream: require.resolve("stream-browserify"),
// buffer: require.resolve("buffer"),
},
},
},
},
};