@@ -5,6 +5,13 @@ module.exports = (api, options) => {
5
5
const getAssetPath = require ( '../util/getAssetPath' )
6
6
const inlineLimit = 4096
7
7
8
+ const genAssetSubPath = dir => {
9
+ return getAssetPath (
10
+ options ,
11
+ `${ dir } /[name]${ options . filenameHashing ? '.[hash:8]' : '' } .[ext]`
12
+ )
13
+ }
14
+
8
15
webpackConfig
9
16
. mode ( 'development' )
10
17
. context ( api . service . context )
@@ -82,10 +89,7 @@ module.exports = (api, options) => {
82
89
. loader ( 'url-loader' )
83
90
. options ( {
84
91
limit : inlineLimit ,
85
- name : getAssetPath (
86
- options ,
87
- `img/[name]${ options . filenameHashing ? '.[hash:8]' : '' } .[ext]`
88
- )
92
+ name : genAssetSubPath ( 'img' )
89
93
} )
90
94
91
95
// do not base64-inline SVGs.
@@ -96,10 +100,7 @@ module.exports = (api, options) => {
96
100
. use ( 'file-loader' )
97
101
. loader ( 'file-loader' )
98
102
. options ( {
99
- name : getAssetPath (
100
- options ,
101
- `img/[name]${ options . filenameHashing ? '.[hash:8]' : '' } .[ext]`
102
- )
103
+ name : genAssetSubPath ( 'img' )
103
104
} )
104
105
105
106
webpackConfig . module
@@ -109,10 +110,7 @@ module.exports = (api, options) => {
109
110
. loader ( 'url-loader' )
110
111
. options ( {
111
112
limit : inlineLimit ,
112
- name : getAssetPath (
113
- options ,
114
- `media/[name]${ options . filenameHashing ? '.[hash:8]' : '' } .[ext]`
115
- )
113
+ name : genAssetSubPath ( 'media' )
116
114
} )
117
115
118
116
webpackConfig . module
@@ -122,10 +120,7 @@ module.exports = (api, options) => {
122
120
. loader ( 'url-loader' )
123
121
. options ( {
124
122
limit : inlineLimit ,
125
- name : getAssetPath (
126
- options ,
127
- `fonts/[name]${ options . filenameHashing ? '.[hash:8]' : '' } .[ext]`
128
- )
123
+ name : genAssetSubPath ( 'fonts' )
129
124
} )
130
125
131
126
// Other common pre-processors ---------------------------------------------
0 commit comments