@@ -151,106 +151,100 @@ module.exports = {
151
151
enforce : 'pre' ,
152
152
include : paths . appSrc ,
153
153
} ,
154
- // ** ADDING/UPDATING LOADERS **
155
- // The "file" loader handles all assets unless explicitly excluded.
156
- // The `exclude` list *must* be updated with every change to loader extensions.
157
- // When adding a new loader, you must add its `test`
158
- // as a new entry in the `exclude` list in the "file" loader.
159
-
160
- // "file" loader makes sure those assets end up in the `build` folder.
161
- // When you `import` an asset, you get its filename.
162
- {
163
- exclude : [
164
- / \. h t m l $ / ,
165
- / \. ( j s | j s x ) $ / ,
166
- / \. ( t s | t s x ) $ / ,
167
- / \. c s s $ / ,
168
- / \. j s o n $ / ,
169
- / \. b m p $ / ,
170
- / \. g i f $ / ,
171
- / \. j p e ? g $ / ,
172
- / \. p n g $ / ,
173
- ] ,
174
- loader : require . resolve ( 'file-loader' ) ,
175
- options : {
176
- name : 'static/media/[name].[hash:8].[ext]' ,
177
- } ,
178
- } ,
179
- // "url" loader works just like "file" loader but it also embeds
180
- // assets smaller than specified size as data URLs to avoid requests.
181
- {
182
- test : [ / \. b m p $ / , / \. g i f $ / , / \. j p e ? g $ / , / \. p n g $ / ] ,
183
- loader : require . resolve ( 'url-loader' ) ,
184
- options : {
185
- limit : 10000 ,
186
- name : 'static/media/[name].[hash:8].[ext]' ,
187
- } ,
188
- } ,
189
- // Compile .tsx?
190
- {
191
- test : / \. ( t s | t s x ) $ / ,
192
- include : paths . appSrc ,
193
- loader : require . resolve ( 'ts-loader' ) ,
194
- options : {
195
- configFileName : 'tsconfig.react.json' ,
196
- } ,
197
- } ,
198
- // The notation here is somewhat confusing.
199
- // "postcss" loader applies autoprefixer to our CSS.
200
- // "css" loader resolves paths in CSS and adds assets as dependencies.
201
- // "style" loader normally turns CSS into JS modules injecting <style>,
202
- // but unlike in development configuration, we do something different.
203
- // `ExtractTextPlugin` first applies the "postcss" and "css" loaders
204
- // (second argument), then grabs the result CSS and puts it into a
205
- // separate file in our build process. This way we actually ship
206
- // a single CSS file in production instead of JS code injecting <style>
207
- // tags. If you use code splitting, however, any async bundles will still
208
- // use the "style" loader inside the async code so CSS from them won't be
209
- // in the main CSS file.
210
154
{
211
- test : / \. c s s $ / ,
212
- loader : ExtractTextPlugin . extract (
213
- Object . assign (
214
- {
215
- fallback : require . resolve ( 'style-loader' ) ,
216
- use : [
217
- {
218
- loader : require . resolve ( 'css-loader' ) ,
219
- options : {
220
- importLoaders : 1 ,
221
- minimize : true ,
222
- sourceMap : true ,
223
- } ,
224
- } ,
155
+ // "oneOf" will traverse all following loaders until one will
156
+ // match the requirements. When no loader matches it will fall
157
+ // back to the "file" loader at the end of the loader list.
158
+ oneOf : [
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 : [ / \. b m p $ / , / \. g i f $ / , / \. j p e ? g $ / , / \. p n g $ / ] ,
163
+ loader : require . resolve ( 'url-loader' ) ,
164
+ options : {
165
+ limit : 10000 ,
166
+ name : 'static/media/[name].[hash:8].[ext]' ,
167
+ } ,
168
+ } ,
169
+ //Compile .tsx?
170
+ {
171
+ test : / \. ( t s | t s x ) $ / ,
172
+ include : paths . appSrc ,
173
+ loader : require . resolve ( 'ts-loader' )
174
+ } ,
175
+ // The notation here is somewhat confusing.
176
+ // "postcss" loader applies autoprefixer to our CSS.
177
+ // "css" loader resolves paths in CSS and adds assets as dependencies.
178
+ // "style" loader normally turns CSS into JS modules injecting <style>,
179
+ // but unlike in development configuration, we do something different.
180
+ // `ExtractTextPlugin` first applies the "postcss" and "css" loaders
181
+ // (second argument), then grabs the result CSS and puts it into a
182
+ // separate file in our build process. This way we actually ship
183
+ // a single CSS file in production instead of JS code injecting <style>
184
+ // tags. If you use code splitting, however, any async bundles will still
185
+ // use the "style" loader inside the async code so CSS from them won't be
186
+ // in the main CSS file.
187
+ {
188
+ test : / \. c s s $ / ,
189
+ loader : ExtractTextPlugin . extract (
190
+ Object . assign (
225
191
{
226
- loader : require . resolve ( 'postcss-loader' ) ,
227
- options : {
228
- // Necessary for external CSS imports to work
229
- // https://github.com/facebookincubator/create-react-app/issues/2677
230
- ident : 'postcss' ,
231
- plugins : ( ) => [
232
- require ( 'postcss-flexbugs-fixes' ) ,
233
- autoprefixer ( {
234
- browsers : [
235
- '>1%' ,
236
- 'last 4 versions' ,
237
- 'Firefox ESR' ,
238
- 'not ie < 9' , // React doesn't support IE8 anyway
192
+ fallback : require . resolve ( 'style-loader' ) ,
193
+ use : [
194
+ {
195
+ loader : require . resolve ( 'css-loader' ) ,
196
+ options : {
197
+ importLoaders : 1 ,
198
+ minimize : true ,
199
+ sourceMap : true ,
200
+ } ,
201
+ } ,
202
+ {
203
+ loader : require . resolve ( 'postcss-loader' ) ,
204
+ options : {
205
+ // Necessary for external CSS imports to work
206
+ // https://github.com/facebookincubator/create-react-app/issues/2677
207
+ ident : 'postcss' ,
208
+ plugins : ( ) => [
209
+ require ( 'postcss-flexbugs-fixes' ) ,
210
+ autoprefixer ( {
211
+ browsers : [
212
+ '>1%' ,
213
+ 'last 4 versions' ,
214
+ 'Firefox ESR' ,
215
+ 'not ie < 9' , // React doesn't support IE8 anyway
216
+ ] ,
217
+ flexbox : 'no-2009' ,
218
+ } ) ,
239
219
] ,
240
- flexbox : 'no-2009' ,
241
- } ) ,
242
- ] ,
243
- } ,
220
+ } ,
221
+ } ,
222
+ ] ,
244
223
} ,
245
- ] ,
224
+ extractTextPluginOptions
225
+ )
226
+ ) ,
227
+ // Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
228
+ } ,
229
+ // "file" loader makes sure assets end up in the `build` folder.
230
+ // When you `import` an asset, you get its filename.
231
+ // This loader don't uses a "test" so it will catch all modules
232
+ // that fall through the other loaders.
233
+ {
234
+ loader : require . resolve ( 'file-loader' ) ,
235
+ // Exclude `js` files to keep "css" loader working as it injects
236
+ // it's runtime that would otherwise processed through "file" loader.
237
+ // Also exclude `html` and `json` extensions so they get processed
238
+ // by webpacks internal loaders.
239
+ exclude : [ / \. j s $ / , / \. h t m l $ / , / \. j s o n $ / ] ,
240
+ options : {
241
+ name : 'static/media/[name].[hash:8].[ext]' ,
246
242
} ,
247
- extractTextPluginOptions
248
- )
249
- ) ,
250
- // Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
243
+ } ,
244
+ // ** STOP ** Are you adding a new loader?
245
+ // Make sure to add the new loader(s) before the "file" loader.
246
+ ] ,
251
247
} ,
252
- // ** STOP ** Are you adding a new loader?
253
- // Remember to add the new extension(s) to the "file" loader exclusion list.
254
248
] ,
255
249
} ,
256
250
plugins : [
0 commit comments