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