-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig-overrides.js
60 lines (58 loc) · 1.59 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
const fs = require('fs')
const path = require('path')
const {
override,
fixBabelImports,
addLessLoader,
addWebpackAlias
} = require('customize-cra')
const appDirectory = fs.realpathSync(process.cwd())
const resolveApp = relativePath => path.resolve(appDirectory, relativePath)
module.exports = {
webpack: override(
fixBabelImports('import', {
libraryName: 'antd',
libraryDirectory: 'es',
style: 'css',
style: true
}),
addLessLoader({
javascriptEnabled: true,
modifyVars: {
'@primary-color': '#639'
}
}),
addWebpackAlias({
'@': resolveApp('src'),
'@module': resolveApp('node_modules'),
'@assets': resolveApp('src/assets'),
'@images': resolveApp('src/assets/images'),
'@fonts': resolveApp('src/assets/fonts'),
'@view': resolveApp('src/view'),
'@store': resolveApp('src/store'),
'@component': resolveApp('src/component'),
'@script': resolveApp('src/script')
}),
config => {
//自定义svg loader方式
const len = config.module.rules[2].oneOf.length
config.module.rules[2].oneOf[1].options.plugins.shift()
config.module.rules[2].oneOf[len - 1].exclude.push(/\.svg$/)
config.module.rules[2].oneOf.push({
test: /\.svg$/,
exclude: /node_modules/,
use: [
{
loader: 'svg-sprite-loader',
options: {
name: '[name]',
prefixize: true,
regExp: resolveApp('src/assets/fonts/svg/(.*)\\.svg')
}
}
]
})
return config
}
)
}