forked from WoWAnalyzer/WoWAnalyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig-overrides.js
55 lines (52 loc) · 2.3 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
const { override, babelInclude } = require('customize-cra');
const path = require('path');
const disablePlugins = (plugins) => (config) => ({
...config,
plugins: config.plugins.filter((plugin) => !plugins.includes(plugin.constructor.name)),
});
const reportPlugins = () => (config) => {
console.log(config.plugins.map((plugin) => plugin.constructor.name));
process.exit();
};
const fixLingui = () => (config) => {
config.module.rules = [
...config.module.rules,
// Fix for lingui loader https://github.com/lingui/js-lingui/issues/1048#issuecomment-822785379
{
resourceQuery: /as-js/,
type: 'javascript/auto',
},
];
return config;
};
module.exports = override(
babelInclude([
path.resolve('./src'),
new RegExp(`^${process.cwd()}/analysis/[^/]+/src/`),
// Hello Windows
new RegExp(`^${process.cwd().replace(/\\/g, '\\\\')}\\\\analysis\\\\[^\\\\]+\\\\src`),
]),
fixLingui(),
// TODO: Support linking packages. The below was disabled since it will make CRA show paths to
// node_modules for errors which make them harder to fix. It also likely makes Babel parse files
// twice, reducing performance. A better solution may be to keep symlinking enabled, and scan
// node_modules to see if any of the workspace-packages have been linked, and add those paths to
// the babelInclude on start. This is a lot more complex though. :(
// babelInclude([
// path.resolve('./src'),
// new RegExp(`^${process.cwd()}/.*/?node_modules/@wowanalyzer/[^/]+/src/`),
// // Temporary directories until these are migrated to workspaces
// new RegExp(`^${process.cwd()}/.*/?node_modules/(interface|parser|common|game|raids)/`),
// ]),
// (config) => {
// // Disabling symlink resolving allows us to link @wowanalyzer packages from any random
// // directory and still have its TypeScript compiled by CRA through the babelInclude above.
// config.resolve.symlinks = false;
// return config;
// },
// customize-cra's disableEsLint disables the rules, but disabling the entire
// plugin seem to give us more performance.
process.env.DISABLE_AUTOMATIC_ESLINT && disablePlugins(['ESLintWebpackPlugin']),
process.env.DISABLE_AUTOMATIC_ESLINT && disablePlugins(['ForkTsCheckerWebpackPlugin']),
// addBabelPlugin('babel-plugin-transform-typescript-metadata'),
);