-
Notifications
You must be signed in to change notification settings - Fork 1
/
config-overrides.js
54 lines (48 loc) · 1.55 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
const tsImportPluginFactory = require("ts-import-plugin");
const {getLoader} = require("react-app-rewired");
const rewireLess = require('react-app-rewire-less');
const rewireYAML = require('react-app-rewire-yaml');
const rewireDefinePlugin = require("react-app-rewire-define-plugin");
module.exports = function override(config, env) {
config = rewireYAML(config, env);
const tsLoader = getLoader(
config.module.rules,
rule =>
rule.loader &&
typeof rule.loader === "string" &&
rule.loader.includes("ts-loader")
);
tsLoader.options = {
getCustomTransformers: () => ({
before: [
tsImportPluginFactory({
libraryDirectory: "es",
libraryName: "antd",
style: true,
}),
],
})
};
config = rewireLess.withLoaderOptions({
modifyVars: require("./theme").antd,
javascriptEnabled: true,
})(config, env);
config = setupProcessEnv(config, env);
return config;
};
function setupProcessEnv(config, env) {
let scope = process.env.SCOPE;
switch (process.env.SCOPE) {
case "testing":
default: {
scope = "development";
consoleLambdaOrigin = "https://cloudcapiv4.herewhite.com";
break;
}
}
config = rewireDefinePlugin(config, env, {
"process.env.SCOPE": JSON.stringify(scope),
"process.env.CONSOLE_LAMBDA_ORIGIN": JSON.stringify(consoleLambdaOrigin),
});
return config;
}