UNPKG

786 BJavaScriptView Raw
1exports.name = 'builtin:config-image'
2
3exports.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 // inline the file if smaller than this size
15 limit: api.config.assets.inlineImageMaxSize
16 })
17
18 config.module
19 .rule('svg')
20 .test(/\.(svg)(\?.*)?$/)
21 .use('file-loader')
22 // SVG files use file-loader directly, why?
23 // See https://github.com/facebookincubator/create-react-app/pull/1180
24 .loader('file-loader')
25 .options({
26 name: filename
27 })
28 })
29}