File tree 2 files changed +42
-22
lines changed
packages/react-scripts/config
2 files changed +42
-22
lines changed Original file line number Diff line number Diff line change @@ -134,15 +134,34 @@ module.exports = {
134
134
// When adding a new loader, you must add its `test`
135
135
// as a new entry in the `exclude` list for "url" loader.
136
136
137
- // "url" loader embeds assets smaller than specified size as data URLs to avoid requests.
138
- // Otherwise, it acts like the "file" loader.
137
+ // "file" loader makes sure those assets get served by WebpackDevServer.
138
+ // When you `import` an asset, you get its (virtual) filename.
139
+ // In production, they would get copied to the `build` folder.
139
140
{
140
141
exclude : [
141
142
/ \. h t m l $ / ,
142
143
/ \. ( j s | j s x ) $ / ,
143
144
/ \. c s s $ / ,
144
145
/ \. j s o n $ / ,
145
- / \. s v g $ /
146
+ / \. b m p $ / ,
147
+ / \. g i f $ / ,
148
+ / \. j p e ? g $ / ,
149
+ / \. p n g $ /
150
+ ] ,
151
+ loader : 'file-loader' ,
152
+ options : {
153
+ name : 'static/media/[name].[hash:8].[ext]'
154
+ }
155
+ } ,
156
+ // "url" loader works like "file" loader except that it embeds assets
157
+ // smaller than specified limit in bytes as data URLs to avoid requests.
158
+ // A missing `test` is equivalent to a match.
159
+ {
160
+ test : [
161
+ / \. b m p $ / ,
162
+ / \. g i f $ / ,
163
+ / \. j p e ? g $ / ,
164
+ / \. p n g $ /
146
165
] ,
147
166
loader : 'url-loader' ,
148
167
options : {
@@ -198,14 +217,6 @@ module.exports = {
198
217
}
199
218
}
200
219
]
201
- } ,
202
- // "file" loader for svg
203
- {
204
- test : / \. s v g $ / ,
205
- loader : 'file-loader' ,
206
- options : {
207
- name : 'static/media/[name].[hash:8].[ext]'
208
- }
209
220
}
210
221
// ** STOP ** Are you adding a new loader?
211
222
// Remember to add the new extension(s) to the "url" loader exclusion list.
Original file line number Diff line number Diff line change @@ -138,15 +138,32 @@ module.exports = {
138
138
// When adding a new loader, you must add its `test`
139
139
// as a new entry in the `exclude` list in the "url" loader.
140
140
141
- // "url " loader embeds assets smaller than specified size as data URLs to avoid requests .
142
- // Otherwise, it acts like the "file" loader .
141
+ // "file " loader makes sure those assets end up in the `build` folder .
142
+ // When you `import` an asset, you get its filename .
143
143
{
144
144
exclude : [
145
145
/ \. h t m l $ / ,
146
146
/ \. ( j s | j s x ) $ / ,
147
147
/ \. c s s $ / ,
148
148
/ \. j s o n $ / ,
149
- / \. s v g $ /
149
+ / \. b m p $ / ,
150
+ / \. g i f $ / ,
151
+ / \. j p e ? g $ / ,
152
+ / \. p n g $ /
153
+ ] ,
154
+ loader : 'file-loader' ,
155
+ query : {
156
+ name : 'static/media/[name].[hash:8].[ext]'
157
+ }
158
+ } ,
159
+ // "url" loader works just like "file" loader but it also embeds
160
+ // assets smaller than specified size as data URLs to avoid requests.
161
+ {
162
+ test : [
163
+ / \. b m p $ / ,
164
+ / \. g i f $ / ,
165
+ / \. j p e ? g $ / ,
166
+ / \. p n g $ /
150
167
] ,
151
168
loader : 'url-loader' ,
152
169
options : {
@@ -209,14 +226,6 @@ module.exports = {
209
226
]
210
227
} , extractTextPluginOptions ) )
211
228
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
212
- } ,
213
- // "file" loader for svg
214
- {
215
- test : / \. s v g $ / ,
216
- loader : 'file-loader' ,
217
- options : {
218
- name : 'static/media/[name].[hash:8].[ext]'
219
- }
220
229
}
221
230
// ** STOP ** Are you adding a new loader?
222
231
// Remember to add the new extension(s) to the "url" loader exclusion list.
You can’t perform that action at this time.
0 commit comments