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