-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcraco.config.js
86 lines (85 loc) · 2.11 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
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
const path = require('path')
module.exports = {
webpack: {
alias: {
'@': path.resolve(__dirname, 'src/')
},
configure: webpackConfig => {
const oneOfRule = webpackConfig.module.rules.find((rule) => rule.oneOf)
if (oneOfRule) {
oneOfRule.oneOf.splice(0, 0, {
test: /\.svg$/,
use: [{
loader: 'svg-sprite-loader',
options: {
extract: false,
}
},
{
loader: 'svgo-loader',
options: {
plugins: [
{
name: 'removeAttrs',
params: {
attrs: 'fill'
}
}
]
}
}
]
})
}
webpackConfig.module.rules.push({
test: /\.md$/,
use: [
{
loader: 'md-loader',
options: {
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: false,
smartLists: true,
smartypants: false
}
}
],
},)
webpackConfig.resolveLoader = {
modules: ['node_modules', './src/loader'],
}
if (process.env.NODE_ENV === "production") {
webpackConfig.optimization.splitChunks = {
...webpackConfig.optimization.splitChunks,
cacheGroups: {
base: {
// 基本框架
chunks: 'all',
test: /(react|react-dom|react-dom-router)/,
name: 'base',
priority: 100,
},
framer: {
chunks: 'all',
test: /(framer-motion)/,
name: 'framer',
priority: 100,
},
commons: {
chunks: 'all',
// 将两个以上的chunk所共享的模块打包至commons组。
minChunks: 2,
name: 'commons',
priority: 80,
},
},
}
}
return webpackConfig
}
},
plugins: []
}