-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig-overrides.js
126 lines (116 loc) · 2.8 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const {
override,
fixBabelImports,
addLessLoader,
addWebpackPlugin,
addWebpackAlias,
getBabelLoader,
addWebpackModuleRule,
tap
} = require('customize-cra');
const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin');
module.exports = {
webpack: override(
config => {
config.devtool = config.mode === 'development'
? 'cheap-module-source-map'
: false
// config.output.publicPath = './'
config.plugins.forEach(item => {
if (item instanceof HtmlWebpackPlugin) {
item.options.version = getVersion()
}
})
config.performance = getPerformance()
return config
},
// tap({ message: "Pre-Customizers" }),
// ****** ant-design config start ******
fixBabelImports('import', {
libraryName: 'antd',
libraryDirectory: 'es',
style: true
}),
addLessLoader({
javascriptEnabled: true,
modifyVars: { '@primary-color': '#1DA57A' }
// modifyVars: { '@primary-color': '#1890ff' }
}),
addWebpackPlugin(new AntdDayjsWebpackPlugin()),
// ****** ant-design config end ******
addWebpackAlias(getAliasConfig()),
//
addWebpackModuleRule(getModuleSassLoaderConfig()),
addWebpackModuleRule(getSassLoaderConfig())
//
// tap({ dest: 'customize-cra.log' })
)
}
function getPerformance() {
return {
hints: false,
maxEntrypointSize: 512000,
maxAssetSize: 512000,
assetFilter: function (assetFilename) {
return assetFilename.endsWith('.js')
}
}
}
function getVersion() {
let date = new Date()
// toJSON 的时区补偿
date.setMinutes(date.getMinutes() - date.getTimezoneOffset())
return date.toJSON().substr(0,19).replace(/[-T:]/g, '')
}
function getAliasConfig() {
return {
'@': path.resolve(__dirname,'src'),
'_com': path.resolve(__dirname,'src/components'),
'_img': path.resolve(__dirname,'src/assets/images'),
'_sty': path.resolve(__dirname,'src/assets/styles')
}
}
function getModuleSassLoaderConfig() {
return {
test: /\.module.s[ac]ss$/i,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[local]_[hash:base64:8]'
}
}
},
{
loader: 'sass-loader',
options: {
prependData: '@import "~@/variables.sass";'
}
}
]
}
}
function getSassLoaderConfig() {
return {
test: /\[^.module].s[ac]ss$/i,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: false
}
},
{
loader: 'sass-loader',
options: {
prependData: '@import "~@/variables.sass";'
}
}
]
}
}