11
11
'use strict' ;
12
12
13
13
const autoprefixer = require ( 'autoprefixer' ) ;
14
- const chalk = require ( 'chalk' ) ;
15
14
const path = require ( 'path' ) ;
16
15
const webpack = require ( 'webpack' ) ;
17
16
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
@@ -27,13 +26,9 @@ const getClientEnvironment = require('./env');
27
26
// Get supported browsers list
28
27
let supportedBrowsers = require ( paths . appPackageJson ) . browserslist ;
29
28
if ( ! supportedBrowsers || Object . keys ( supportedBrowsers ) . length === 0 ) {
30
- console . log (
31
- chalk . yellow (
32
- 'You can now specify targeted browsers by adding "browserslist" key in "package.json" as per User Documentation'
33
- )
34
- ) ;
35
29
// Assign default browsers when browserslist is not specified
36
- supportedBrowsers = "browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9', // React doesn't support IE8 anyway]" ;
30
+ supportedBrowsers =
31
+ "browsers: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 9', // React doesn't support IE8 anyway]" ;
37
32
}
38
33
39
34
// Webpack uses `publicPath` to determine where the app is being served from.
@@ -88,9 +83,11 @@ module.exports = {
88
83
chunkFilename : 'static/js/[name].[chunkhash:8].chunk.js' ,
89
84
// We inferred the "public path" (such as / or /my-project) from homepage.
90
85
publicPath : publicPath ,
91
- // Point sourcemap entries to original disk location
86
+ // Point sourcemap entries to original disk location (format as URL on Windows)
92
87
devtoolModuleFilenameTemplate : info =>
93
- path . relative ( paths . appSrc , info . absoluteResourcePath ) ,
88
+ path
89
+ . relative ( paths . appSrc , info . absoluteResourcePath )
90
+ . replace ( / \\ / g, '/' ) ,
94
91
} ,
95
92
resolve : {
96
93
// This allows you to set a fallback for where Webpack should look for modules.
@@ -105,7 +102,9 @@ module.exports = {
105
102
// We also include JSX as a common component filename extension to support
106
103
// some tools, although we do not recommend using it, see:
107
104
// https://github.com/facebookincubator/create-react-app/issues/290
108
- extensions : [ '.js' , '.json' , '.jsx' ] ,
105
+ // `web` extension prefixes have been added for better support
106
+ // for React Native Web.
107
+ extensions : [ '.web.js' , '.js' , '.json' , '.web.jsx' , '.jsx' ] ,
109
108
alias : {
110
109
// @remove -on-eject-begin
111
110
// Resolve Babel runtime relative to react-scripts.
@@ -199,12 +198,13 @@ module.exports = {
199
198
test : / \. ( j s | j s x ) $ / ,
200
199
include : paths . appSrc ,
201
200
loader : require . resolve ( 'babel-loader' ) ,
202
- // @remove -on-eject-begin
203
201
options : {
202
+ // @remove -on-eject-begin
204
203
babelrc : false ,
205
204
presets : [ require . resolve ( 'babel-preset-react-app' ) ] ,
205
+ // @remove -on-eject-end
206
+ compact : true ,
206
207
} ,
207
- // @remove -on-eject-end
208
208
} ,
209
209
// The notation here is somewhat confusing.
210
210
// "postcss" loader applies autoprefixer to our CSS.
@@ -236,10 +236,10 @@ module.exports = {
236
236
{
237
237
loader : require . resolve ( 'postcss-loader' ) ,
238
238
options : {
239
- ident : 'postcss' , // https://webpack.js.org/guides/migrating/#complex-options
240
239
plugins : ( ) => [
241
240
require ( 'postcss-flexbugs-fixes' ) ,
242
241
autoprefixer ( {
242
+ supportedBrowsers,
243
243
flexbox : 'no-2009' ,
244
244
} ) ,
245
245
] ,
@@ -297,6 +297,9 @@ module.exports = {
297
297
} ,
298
298
output : {
299
299
comments : false ,
300
+ // Turned on because emoji and regex is not minified properly using default
301
+ // https://github.com/facebookincubator/create-react-app/issues/2488
302
+ ascii_only : true ,
300
303
} ,
301
304
sourceMap : true ,
302
305
} ) ,
@@ -324,6 +327,11 @@ module.exports = {
324
327
// This message occurs for every build and is a bit too noisy.
325
328
return ;
326
329
}
330
+ if ( message . indexOf ( 'Skipping static resource' ) === 0 ) {
331
+ // This message obscures real errors so we ignore it.
332
+ // https://github.com/facebookincubator/create-react-app/issues/2612
333
+ return ;
334
+ }
327
335
console . log ( message ) ;
328
336
} ,
329
337
minify : true ,
@@ -334,9 +342,6 @@ module.exports = {
334
342
navigateFallbackWhitelist : [ / ^ (? ! \/ _ _ ) .* / ] ,
335
343
// Don't precache sourcemaps (they're large) and build asset manifest:
336
344
staticFileGlobsIgnorePatterns : [ / \. m a p $ / , / a s s e t - m a n i f e s t \. j s o n $ / ] ,
337
- // Work around Windows path issue in SWPrecacheWebpackPlugin:
338
- // https://github.com/facebookincubator/create-react-app/issues/2235
339
- stripPrefix : paths . appBuild . replace ( / \\ / g, '/' ) + '/' ,
340
345
} ) ,
341
346
// Moment.js is an extremely popular library that bundles large locale files
342
347
// by default due to how Webpack interprets its code. This is a practical
@@ -348,6 +353,7 @@ module.exports = {
348
353
// Some libraries import Node modules but don't use them in the browser.
349
354
// Tell Webpack to provide empty mocks for them so importing them works.
350
355
node : {
356
+ dgram : 'empty' ,
351
357
fs : 'empty' ,
352
358
net : 'empty' ,
353
359
tls : 'empty' ,
0 commit comments