-
Notifications
You must be signed in to change notification settings - Fork 2
/
craco.config.js
53 lines (52 loc) · 1.52 KB
/
craco.config.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
const CracoAntDesignPlugin = require('craco-antd')
const slash = require('slash2')
module.exports = {
babel: {
plugins: [
[
'@babel/plugin-proposal-decorators',
{
// https://babeljs.io/blog/2018/09/17/decorators
// https://github.com/mobxjs/mobx/issues/1352
legacy: true
}
]
]
},
plugins: [
{
plugin: CracoAntDesignPlugin,
options: {
lessLoaderOptions: {
modifyVars: { '@primary-color': '#48c75b' },
// strictMath: true,
// noIeCompat: true,
javascriptEnabled: true
},
cssLoaderOptions: {
modules: true,
// localIdentName: '[local]',
getLocalIdent: (context, localIdentName, localName) => {
if (
context.resourcePath.includes('node_modules') ||
context.resourcePath.includes('ant.design.pro.less') ||
context.resourcePath.includes('global.less')
) {
return localName
}
const match = context.resourcePath.match(/src(.*)/)
if (match && match[1]) {
const antdProPath = match[1].replace('.less', '')
const arr = slash(antdProPath)
.split('/')
.map(a => a.replace(/([A-Z])/g, '-$1'))
.map(a => a.toLowerCase())
return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-')
}
return localName
}
}
}
}
]
}