-
Notifications
You must be signed in to change notification settings - Fork 1
/
config-overrides.js
73 lines (64 loc) · 2.36 KB
/
config-overrides.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
// This file is used together with react-scripts-rewire to overwrite the webpack config of your CRA App to add capability for:
// Typescript Decorators
const { override, addBabelPlugin } = require("customize-cra");
const babelTsTransformPlugin = require("babel-plugin-transform-typescript-metadata");
const path = require("path");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
// Environment Variables can be set here
// IMPORTANT: environment variables, that contain a Secret are set in .env.development or .env.production
process.env.GENERATE_SOURCEMAP = "false"; // disable sourcemap generation (removes warnings while building)
module.exports = {
webpack: override(addBabelPlugin(babelTsTransformPlugin), (config) => {
const fallback = config.resolve.fallback || {};
Object.assign(fallback, {
path: require.resolve("path-browserify"),
fs: false,
});
config.resolve.fallback = fallback;
config.resolve.plugins = [new TsconfigPathsPlugin()];
return config;
}),
jest: (config) => {
config.preset = "ts-jest";
config.testEnvironment = "jsdom";
config.transformIgnorePatterns = [
"<rootDir>/node_modules/(?!((@babylonjs)|(axios)|(earcut)|(history)(.*)))",
];
config.testPathIgnorePatterns = ["<rootDir>/node_modules/"];
config.collectCoverage = true;
config.coveragePathIgnorePatterns = [
"/node_modules/",
"/*.test.ts",
"/DependencyInjection/",
"/Entities/",
"/[A-z]*Debug[A-z]*.ts",
"/[A-z]*Test[A-z]*/",
"index.ts",
];
config.coverageReporters = ["text-summary", "lcov"];
config.coverageThreshold = {
global: {
branches: 0,
functions: 0,
lines: 0,
statements: 92,
},
};
config.setupFilesAfterEnv = ["./jest-setup-files.ts"];
config.verbose = true;
config.moduleNameMapper = addJestMappings();
return config;
},
};
function addJestMappings() {
const tsConfig = require(path.resolve(__dirname, "tsconfig.json"));
const obj = {};
for (const key in tsConfig.compilerOptions.paths) {
obj["^" + key.replace("/*", "(.*)$")] =
"<rootDir>/" +
tsConfig.compilerOptions.paths[key][0].replace("/*", "/$1");
}
obj["^src/(.*)$"] = "<rootDir>/src/$1";
obj["\\.(css|less)$"] = "identity-obj-proxy"; // mock css imports (needed for ReactFlow stylesheet)
return obj;
}