@@ -33,17 +33,24 @@ const getClientEnvironment = require('./env');
3333const ModuleNotFoundPlugin = require ( 'react-dev-utils/ModuleNotFoundPlugin' ) ;
3434const ForkTsCheckerWebpackPlugin = require ( 'react-dev-utils/ForkTsCheckerWebpackPlugin' ) ;
3535const typescriptFormatter = require ( 'react-dev-utils/typescriptFormatter' ) ;
36+ const eslint = require ( 'eslint' ) ;
3637// @remove -on-eject-begin
3738const getCacheIdentifier = require ( 'react-dev-utils/getCacheIdentifier' ) ;
3839// @remove -on-eject-end
3940const postcssNormalize = require ( 'postcss-normalize' ) ;
4041
42+ const appPackageJson = require ( paths . appPackageJson ) ;
43+
4144// Source maps are resource heavy and can cause out of memory issue for large source files.
4245const shouldUseSourceMap = process . env . GENERATE_SOURCEMAP !== 'false' ;
4346// Some apps do not need the benefits of saving a web request, so not inlining the chunk
4447// makes for a smoother build process.
4548const shouldInlineRuntimeChunk = process . env . INLINE_RUNTIME_CHUNK !== 'false' ;
4649
50+ const imageInlineSizeLimit = parseInt (
51+ process . env . IMAGE_INLINE_SIZE_LIMIT || '10000'
52+ ) ;
53+
4754// Check if TypeScript is setup
4855const useTypeScript = fs . existsSync ( paths . appTsConfig ) ;
4956
@@ -117,12 +124,20 @@ module.exports = function(webpackEnv) {
117124 } ,
118125 ] . filter ( Boolean ) ;
119126 if ( preProcessor ) {
120- loaders . push ( {
121- loader : require . resolve ( preProcessor ) ,
122- options : {
123- sourceMap : isEnvProduction && shouldUseSourceMap ,
127+ loaders . push (
128+ {
129+ loader : require . resolve ( 'resolve-url-loader' ) ,
130+ options : {
131+ sourceMap : isEnvProduction && shouldUseSourceMap ,
132+ } ,
124133 } ,
125- } ) ;
134+ {
135+ loader : require . resolve ( preProcessor ) ,
136+ options : {
137+ sourceMap : true ,
138+ } ,
139+ }
140+ ) ;
126141 }
127142 return loaders ;
128143 } ;
@@ -184,6 +199,9 @@ module.exports = function(webpackEnv) {
184199 . replace ( / \\ / g, '/' )
185200 : isEnvDevelopment &&
186201 ( info => path . resolve ( info . absoluteResourcePath ) . replace ( / \\ / g, '/' ) ) ,
202+ // Prevents conflicts when multiple Webpack runtimes (from different apps)
203+ // are used on the same page.
204+ jsonpFunction : `webpackJsonp${ appPackageJson . name } ` ,
187205 } ,
188206 optimization : {
189207 minimize : isEnvProduction ,
@@ -192,8 +210,8 @@ module.exports = function(webpackEnv) {
192210 new TerserPlugin ( {
193211 terserOptions : {
194212 parse : {
195- // we want terser to parse ecma 8 code. However, we don't want it
196- // to apply any minfication steps that turns valid ecma 5 code
213+ // We want terser to parse ecma 8 code. However, we don't want it
214+ // to apply any minification steps that turns valid ecma 5 code
197215 // into invalid ecma 5 code. This is why the 'compress' and 'output'
198216 // sections only apply transformations that are ecma 5 safe
199217 // https://github.com/facebook/create-react-app/pull/4234
@@ -209,7 +227,7 @@ module.exports = function(webpackEnv) {
209227 comparisons : false ,
210228 // Disabled because of an issue with Terser breaking valid code:
211229 // https://github.com/facebook/create-react-app/issues/5250
212- // Pending futher investigation:
230+ // Pending further investigation:
213231 // https://github.com/terser-js/terser/issues/120
214232 inline : 2 ,
215233 } ,
@@ -318,10 +336,26 @@ module.exports = function(webpackEnv) {
318336 options : {
319337 formatter : require . resolve ( 'react-dev-utils/eslintFormatter' ) ,
320338 eslintPath : require . resolve ( 'eslint' ) ,
339+ resolvePluginsRelativeTo : __dirname ,
321340 // @remove -on-eject-begin
322- baseConfig : {
323- extends : [ require . resolve ( 'eslint-config-react-app' ) ] ,
324- } ,
341+ baseConfig : ( ( ) => {
342+ const eslintCli = new eslint . CLIEngine ( ) ;
343+ let eslintConfig ;
344+ try {
345+ eslintConfig = eslintCli . getConfigForFile ( paths . appIndexJs ) ;
346+ } catch ( e ) {
347+ // A config couldn't be found.
348+ }
349+
350+ // We allow overriding the config only if the env variable is set
351+ if ( process . env . EXTEND_ESLINT && eslintConfig ) {
352+ return eslintConfig ;
353+ } else {
354+ return {
355+ extends : [ require . resolve ( 'eslint-config-react-app' ) ] ,
356+ } ;
357+ }
358+ } ) ( ) ,
325359 ignore : false ,
326360 useEslintrc : false ,
327361 // @remove -on-eject-end
@@ -343,7 +377,7 @@ module.exports = function(webpackEnv) {
343377 test : [ / \. b m p $ / , / \. g i f $ / , / \. j p e ? g $ / , / \. p n g $ / ] ,
344378 loader : require . resolve ( 'url-loader' ) ,
345379 options : {
346- limit : 10000 ,
380+ limit : imageInlineSizeLimit ,
347381 name : 'static/media/[name].[hash:8].[ext]' ,
348382 } ,
349383 } ,
@@ -384,7 +418,8 @@ module.exports = function(webpackEnv) {
384418 {
385419 loaderMap : {
386420 svg : {
387- ReactComponent : '@svgr/webpack?-svgo,+ref![path]' ,
421+ ReactComponent :
422+ '@svgr/webpack?-svgo,+titleProp,+ref![path]' ,
388423 } ,
389424 } ,
390425 } ,
@@ -623,9 +658,11 @@ module.exports = function(webpackEnv) {
623658 navigateFallbackBlacklist : [
624659 // Exclude URLs starting with /_, as they're likely an API call
625660 new RegExp ( '^/_' ) ,
626- // Exclude URLs containing a dot, as they're likely a resource in
627- // public/ and not a SPA route
628- new RegExp ( '/[^/]+\\.[^/]+$' ) ,
661+ // Exclude any URLs whose last part seems to be a file extension
662+ // as they're likely a resource and not a SPA route.
663+ // URLs containing a "?" character won't be blacklisted as they're likely
664+ // a route with query params (e.g. auth callbacks).
665+ new RegExp ( '/[^/?]+\\.[^/]+$' ) ,
629666 ] ,
630667 } ) ,
631668 // TypeScript type checking
0 commit comments