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