-
Notifications
You must be signed in to change notification settings - Fork 9
/
config-overrides.js
94 lines (89 loc) · 2.49 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
const {
override,
getBabelLoader,
addDecoratorsLegacy,
fixBabelImports,
disableEsLint,
addLessLoader,
addWebpackAlias,
addBabelPlugin,
useBabelRc,
addTslintLoader,
} = require("customize-cra");
const path = require("path");
const Color = require("color");
function resolve(...dir) {
return path.join(__dirname, ...dir);
}
function resolveSrc(...dir) {
return path.join(__dirname, "src", ...dir);
}
function rewireSVGR(svgrLoaderOptions) {
return function(config) {
const svgReactLoader = {
test: /\.svg$/,
use: [
{
loader: require.resolve(`@svgr/webpack`),
options: svgrLoaderOptions,
},
{
loader: "url-loader",
},
],
};
config.module.rules.unshift(svgReactLoader);
return config;
};
}
const primaryColor = "#19263a";
module.exports = override(
addDecoratorsLegacy(),
disableEsLint(),
// useBabelRc(),
// rewireSVGR({ icon: true }),
fixBabelImports("antd", {
libraryName: "antd",
libraryDirectory: "es",
style: true,
}),
fixBabelImports("antd-mobile", { libraryName: "antd-mobile", libraryDirectory: "lib" }),
fixBabelImports("lodash", {
libraryName: "lodash",
libraryDirectory: "",
camel2DashComponentName: false, // default: true
}),
addWebpackAlias({
["@"]: resolve("src"),
["@components"]: resolveSrc("components"),
["@context"]: resolveSrc("context"),
["@routes"]: resolveSrc("routes"),
["@resources"]: resolveSrc("resources"),
["@icons"]: resolveSrc("resources", "icons"),
["@helpers"]: resolveSrc("helpers"),
["@common"]: resolveSrc("common"),
}),
addLessLoader({
javascriptEnabled: true,
modifyVars: {
// https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less
"@primary-color": primaryColor,
"@layout-body-background": "white",
"@menu-dark-color": "white",
"@menu-dark-bg": primaryColor,
"@menu-highlight-color": Color(primaryColor)
.lighten(0.2)
.hex(),
"@item-active-bg": Color(primaryColor)
.lighten(0.2)
.hex(),
"@item-hover-bg": Color(primaryColor)
.lighten(0.2)
.hex(),
"@menu-dark-item-active-bg": "#E94A37",
"@font-family": `"Lato", "IBM Plex Sans Condensed", "Helvetica Neue", Arial, sans-serif`,
"@code-family": `"Source Code Pro", "IBM Plex Mono", "Menlo", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", Courier, monospace`,
},
}),
addTslintLoader()
);