1 | exports.name = 'builtin:config-image'
|
2 |
|
3 | exports.apply = api => {
|
4 | api.hook('createWebpackChain', config => {
|
5 | const filename = api.config.output.fileNames.image
|
6 |
|
7 | config.module
|
8 | .rule('image')
|
9 | .test([/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/, /\.webp$/])
|
10 | .use('url-loader')
|
11 | .loader('url-loader')
|
12 | .options({
|
13 | name: filename,
|
14 |
|
15 | limit: api.config.assets.inlineImageMaxSize
|
16 | })
|
17 |
|
18 | config.module
|
19 | .rule('svg')
|
20 | .test(/\.(svg)(\?.*)?$/)
|
21 | .use('file-loader')
|
22 |
|
23 |
|
24 | .loader('file-loader')
|
25 | .options({
|
26 | name: filename
|
27 | })
|
28 | })
|
29 | }
|