-
Notifications
You must be signed in to change notification settings - Fork 4
/
config-overrides.js
96 lines (83 loc) · 3.6 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const webpack = require("webpack");
const path = require("path");
const ModuleScopePlugin = require("react-dev-utils/ModuleScopePlugin");
const resolvePath = (relativePath) => path.resolve(__dirname, relativePath);
const appIncludes = [resolvePath("./src")];
module.exports = {
// The Webpack config to use when compiling your react app for development or production.
webpack: (config, env) => {
config.resolve.plugins = config.resolve.plugins.filter(
(plugin) => !(plugin instanceof ModuleScopePlugin),
);
// config.module.rules[0].include = appIncludes;
// const jsConfig = config.module.rules.find(({ include }) => include);
// jsConfig.include = appIncludes;
const __DEV__ = env !== "production";
config.plugins.push(new webpack.DefinePlugin({ __DEV__ }));
return config;
},
// The Jest config to use when running your jest tests - note that the normal rewires do not
// work here.
jest: function (config) {
// ...add your jest config customisation...
// Example: enable/disable some tests based on environment variables in the .env file.
// if (!config.testPathIgnorePatterns) {
// config.testPathIgnorePatterns = [];
// }
// if (!process.env.RUN_COMPONENT_TESTS) {
// config.testPathIgnorePatterns.push(
// '<rootDir>/src/components/**/*.test.js',
// );
// }
// if (!process.env.RUN_REDUCER_TESTS) {
// config.testPathIgnorePatterns.push('<rootDir>/src/reducers/**/*.test.js');
// }
// config.rootDir = path.join(__dirname, "../");
// config.roots = [...config.roots, "<rootDir>/src"];
// (config.testMatch = [
// "<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
// "<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}",
// ]),
config.setupFiles = [
...(config.setupFiles || []),
path.join(__dirname, "./path/jestSetupFile.js"),
];
config.globals = {
...config.globals,
__DEV__: true,
};
config.testPathIgnorePatterns = [
...(config.testPathIgnorePatterns || []),
"/node_modules/",
];
return config;
},
// The function to use to create a webpack dev server configuration when running the development
// server with 'npm run start' or 'yarn start'.
// Example: set the dev server to use a specific certificate in https.
devServer: function (configFunction) {
// Return the replacement function for create-react-app to use to generate the Webpack
// Development Server config. "configFunction" is the function that would normally have
// been used to generate the Webpack Development server config - you can use it to create
// a starting configuration to then modify instead of having to create a config from scratch.
return function (proxy, allowedHost) {
// Create the default config by calling configFunction with the proxy/allowedHost parameters
const config = configFunction(proxy, allowedHost);
// Change the https certificate options to match your certificate, using the .env file to
// set the file paths & passphrase.
// config.https = {
// key: fs.readFileSync(process.env.REACT_HTTPS_KEY, 'utf8'),
// cert: fs.readFileSync(process.env.REACT_HTTPS_CERT, 'utf8'),
// ca: fs.readFileSync(process.env.REACT_HTTPS_CA, 'utf8'),
// passphrase: process.env.REACT_HTTPS_PASS,
// };
// Return your customised Webpack Development Server config.
return config;
};
},
// The paths config to use when compiling your react app for development or production.
paths: function (paths, env) {
// ...add your paths config
return paths;
},
};