@@ -12,7 +12,7 @@ const TerserPlugin = require("terser-webpack-plugin");
12
12
const MiniCssExtractPlugin = require ( "mini-css-extract-plugin" ) ;
13
13
const OptimizeCSSAssetsPlugin = require ( "optimize-css-assets-webpack-plugin" ) ;
14
14
const safePostCssParser = require ( "postcss-safe-parser" ) ;
15
- const ManifestPlugin = require ( "webpack-manifest-plugin" ) ;
15
+ const { WebpackManifestPlugin } = require ( "webpack-manifest-plugin" ) ;
16
16
const InterpolateHtmlPlugin = require ( "react-dev-utils/InterpolateHtmlPlugin" ) ;
17
17
const WorkboxWebpackPlugin = require ( "workbox-webpack-plugin" ) ;
18
18
const WatchMissingNodeModulesPlugin = require ( "react-dev-utils/WatchMissingNodeModulesPlugin" ) ;
@@ -107,23 +107,25 @@ module.exports = function (webpackEnv) {
107
107
// package.json
108
108
loader : require . resolve ( "postcss-loader" ) ,
109
109
options : {
110
- // Necessary for external CSS imports to work
111
- // https://github.com/facebook/create-react-app/issues/2677
112
- ident : "postcss" ,
113
- plugins : ( ) => [
114
- require ( "postcss-flexbugs-fixes" ) ,
115
- require ( "postcss-preset-env" ) ( {
116
- autoprefixer : {
117
- flexbox : "no-2009" ,
118
- } ,
119
- stage : 3 ,
120
- } ) ,
121
- // Adds PostCSS Normalize as the reset css with default options,
122
- // so that it honors browserslist config in package.json
123
- // which in turn let's users customize the target behavior as per their needs.
124
- postcssNormalize ( ) ,
125
- ] ,
126
- sourceMap : isEnvProduction ? shouldUseSourceMap : isEnvDevelopment ,
110
+ postcssOptions : {
111
+ plugins : [
112
+ require ( 'postcss-flexbugs-fixes' ) ,
113
+ [
114
+ require ( 'postcss-preset-env' ) ,
115
+ {
116
+ autoprefixer : {
117
+ flexbox : 'no-2009' ,
118
+ } ,
119
+ stage : 3 ,
120
+ } ,
121
+ ] ,
122
+ // Adds PostCSS Normalize as the reset css with default options,
123
+ // so that it honors browserslist config in package.json
124
+ // which in turn let's users customize the target behavior as per their needs.
125
+ postcssNormalize ( ) ,
126
+ ] ,
127
+ } ,
128
+ sourceMap : isEnvProduction && shouldUseSourceMap ,
127
129
} ,
128
130
} ,
129
131
] . filter ( Boolean ) ;
@@ -167,9 +169,7 @@ module.exports = function (webpackEnv) {
167
169
// There will be one main bundle, and one file per asynchronous chunk.
168
170
filename : isEnvProduction
169
171
? "js/[name].[contenthash:8].js"
170
- : isEnvDevelopment && "js/bundle.js" ,
171
- // TODO: remove this when upgrading to webpack 5
172
- futureEmitAssets : true ,
172
+ : isEnvDevelopment && "js/[name].js" ,
173
173
// There are also additional JS chunk files if you use code splitting.
174
174
chunkFilename : isEnvProduction
175
175
? "js/[name].[contenthash:8].chunk.js"
@@ -187,9 +187,6 @@ module.exports = function (webpackEnv) {
187
187
: isEnvDevelopment &&
188
188
( ( info ) =>
189
189
path . resolve ( info . absoluteResourcePath ) . replace ( / \\ / g, "/" ) ) ,
190
- // Prevents conflicts when multiple webpack runtimes (from different apps)
191
- // are used on the same page.
192
- jsonpFunction : `webpackJsonp${ appPackageJson . name } ` ,
193
190
// this defaults to 'window', but by setting it to 'this' then
194
191
// module chunks which are built will work in web workers as well.
195
192
globalObject : "this" ,
@@ -236,7 +233,6 @@ module.exports = function (webpackEnv) {
236
233
ascii_only : true ,
237
234
} ,
238
235
} ,
239
- sourceMap : shouldUseSourceMap ,
240
236
} ) ,
241
237
// This is only used in production mode
242
238
new OptimizeCSSAssetsPlugin ( {
@@ -589,7 +585,7 @@ module.exports = function (webpackEnv) {
589
585
// `index.html`
590
586
// - "entrypoints" key: Array of files which are included in `index.html`,
591
587
// can be used to reconstruct the HTML if necessary
592
- new ManifestPlugin ( {
588
+ new WebpackManifestPlugin ( {
593
589
fileName : "asset-manifest.json" ,
594
590
publicPath : paths . publicUrlOrPath ,
595
591
generate : ( seed , files , entrypoints ) => {
@@ -612,7 +608,10 @@ module.exports = function (webpackEnv) {
612
608
// solution that requires the user to opt into importing specific locales.
613
609
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
614
610
// You can remove this if you don't use Moment.js:
615
- new webpack . IgnorePlugin ( / ^ \. \/ l o c a l e $ / , / m o m e n t $ / ) ,
611
+ new webpack . IgnorePlugin ( {
612
+ resourceRegExp : / ^ \. \/ l o c a l e $ / ,
613
+ contextRegExp : / m o m e n t $ / ,
614
+ } ) ,
616
615
// Generate a service worker script that will precache, and keep up to date,
617
616
// the HTML & assets that are part of the webpack build.
618
617
isEnvProduction &&
@@ -628,34 +627,46 @@ module.exports = function (webpackEnv) {
628
627
} ) ,
629
628
// TypeScript type checking
630
629
useTypeScript &&
631
- new ForkTsCheckerWebpackPlugin ( {
632
- typescript : resolve . sync ( "typescript" , {
630
+ new ForkTsCheckerWebpackPlugin ( {
631
+ typescript : {
632
+ typescriptPath : resolve . sync ( 'typescript' , {
633
633
basedir : paths . appNodeModules ,
634
634
} ) ,
635
- async : false ,
636
- checkSyntacticErrors : true ,
637
- resolveModuleNameModule : process . versions . pnp
638
- ? `${ __dirname } /pnpTs.js`
639
- : undefined ,
640
- resolveTypeReferenceDirectiveModule : process . versions . pnp
641
- ? `${ __dirname } /pnpTs.js`
642
- : undefined ,
643
- tsconfig : paths . appTsConfig ,
644
- reportFiles : [
645
- // This one is specifically to match during CI tests,
646
- // as micromatch doesn't match
647
- // '../cra-template-typescript/template/src/App.tsx'
648
- // otherwise.
649
- "../**/src/**/*.{ts,tsx}" ,
650
- "**/src/**/*.{ts,tsx}" ,
651
- "!**/src/**/__tests__/**" ,
652
- "!**/src/**/?(*.)(spec|test).*" ,
653
- "!**/src/setupProxy.*" ,
654
- "!**/src/setupTests.*" ,
655
- ] ,
656
- silent : true ,
657
- formatter : typescriptFormatter ,
658
- } ) ,
635
+ configOverwrite : {
636
+ compilerOptions : {
637
+ sourceMap : isEnvProduction
638
+ ? shouldUseSourceMap
639
+ : isEnvDevelopment ,
640
+ skipLibCheck : true ,
641
+ inlineSourceMap : false ,
642
+ declarationMap : false ,
643
+ noEmit : true ,
644
+ incremental : true ,
645
+ } ,
646
+ } ,
647
+ context : paths . appPath ,
648
+ diagnosticOptions : {
649
+ syntactic : true ,
650
+ } ,
651
+ mode : 'write-references' ,
652
+ // profile: true,
653
+ } ,
654
+ issue : {
655
+ include : [
656
+ '../**/src/**/*.{ts,tsx}' ,
657
+ '**/src/**/*.{ts,tsx}' ,
658
+ ] . map ( file => ( { file } ) ) ,
659
+ exclude : [
660
+ '**/src/**/__tests__/**' ,
661
+ '**/src/**/?(*.)(spec|test).*' ,
662
+ '**/src/setupProxy.*' ,
663
+ '**/src/setupTests.*' ,
664
+ ] . map ( file => ( { file } ) ) ,
665
+ } ,
666
+ logger : {
667
+ infrastructure : 'silent' ,
668
+ } ,
669
+ } ) ,
659
670
// new ESLintPlugin({
660
671
// // Plugin options
661
672
// extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
@@ -676,18 +687,6 @@ module.exports = function (webpackEnv) {
676
687
// },
677
688
// }),
678
689
] . filter ( Boolean ) ,
679
- // Some libraries import Node modules but don't use them in the browser.
680
- // Tell webpack to provide empty mocks for them so importing them works.
681
- node : {
682
- module : "empty" ,
683
- dgram : "empty" ,
684
- dns : "mock" ,
685
- fs : "empty" ,
686
- http2 : "empty" ,
687
- net : "empty" ,
688
- tls : "empty" ,
689
- child_process : "empty" ,
690
- } ,
691
690
// Turn off performance processing because we utilize
692
691
// our own hints via the FileSizeReporter
693
692
performance : false ,
0 commit comments