-
-
Notifications
You must be signed in to change notification settings - Fork 172
/
Copy pathcraco.config.js
70 lines (64 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* eslint-disable import/no-extraneous-dependencies */
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const ForkTSCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
const { pathsToModuleNameMapper } = require("ts-jest");
const { compilerOptions } = require("./tsconfig.paths.json");
module.exports = {
eslint: { enable: false },
webpack: {
configure: (config) => {
// Remove ModuleScopePlugin which throws when we try to import something
// outside of src/.
config.resolve.plugins.pop();
// Resolve the path aliases.
config.resolve.plugins.push(new TsconfigPathsPlugin());
// Let Babel compile outside of src/.
const oneOfRule = config.module.rules.find((rule) => rule.oneOf);
const tsRule = oneOfRule.oneOf.find((rule) =>
rule.test.toString().includes("ts|tsx")
);
tsRule.include = undefined;
tsRule.exclude = /node_modules/;
return config;
},
plugins: {
remove: [
// This plugin is too old and causes problems in monorepos. We'll
// replace it with a newer version.
"ForkTsCheckerWebpackPlugin",
],
add: [
// Use newer version of ForkTSCheckerWebpackPlugin to type check
// files across the monorepo.
new ForkTSCheckerWebpackPlugin({
issue: {
// The exclude rules are copied from CRA.
exclude: [
{
file: "**/src/**/__tests__/**",
},
{
file: "**/src/**/?(*.)(spec|test).*",
},
{
file: "**/src/setupProxy.*",
},
{
file: "**/src/setupTests.*",
},
],
},
}),
],
},
},
jest: {
configure: {
preset: "ts-jest",
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
// This has to match the baseUrl defined in tsconfig.json.
prefix: "<rootDir>/",
}),
},
},
};