@griddo/ax 12.2.2 → 12.2.3-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/__tests__/webpack5-migration.test.js +436 -0
- package/config/webpack.config.js +153 -189
- package/config/webpackDevServer.config.js +59 -93
- package/config/webpackSchemas.config.js +6 -1
- package/package.json +20 -26
- package/scripts/build.js +4 -0
- package/scripts/start.js +8 -9
- package/src/modules/App/Routing/NavMenu/index.tsx +4 -2
- package/config/pnpTs.js +0 -15
package/config/webpack.config.js
CHANGED
|
@@ -2,26 +2,23 @@ const fs = require("fs");
|
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const webpack = require("webpack");
|
|
4
4
|
const resolve = require("resolve");
|
|
5
|
-
const PnpWebpackPlugin = require("pnp-webpack-plugin");
|
|
6
5
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
7
6
|
const CaseSensitivePathsPlugin = require("case-sensitive-paths-webpack-plugin");
|
|
8
7
|
const InlineChunkHtmlPlugin = require("react-dev-utils/InlineChunkHtmlPlugin");
|
|
9
8
|
const TerserPlugin = require("terser-webpack-plugin");
|
|
10
9
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const ManifestPlugin = require("webpack-manifest-plugin");
|
|
10
|
+
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
|
|
11
|
+
const { WebpackManifestPlugin } = require("webpack-manifest-plugin");
|
|
14
12
|
const InterpolateHtmlPlugin = require("react-dev-utils/InterpolateHtmlPlugin");
|
|
15
|
-
const WorkboxWebpackPlugin = require("workbox-webpack-plugin");
|
|
16
|
-
const WatchMissingNodeModulesPlugin = require("react-dev-utils/WatchMissingNodeModulesPlugin");
|
|
17
13
|
const getCSSModuleLocalIdent = require("react-dev-utils/getCSSModuleLocalIdent");
|
|
18
14
|
const paths = require("./paths");
|
|
19
15
|
const modules = require("./modules");
|
|
20
16
|
const getClientEnvironment = require("./env");
|
|
21
17
|
const ModuleNotFoundPlugin = require("react-dev-utils/ModuleNotFoundPlugin");
|
|
22
18
|
const ForkTsCheckerWebpackPlugin = require("react-dev-utils/ForkTsCheckerWebpackPlugin");
|
|
23
|
-
const typescriptFormatter = require("react-dev-utils/typescriptFormatter");
|
|
24
19
|
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
|
|
20
|
+
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
|
|
21
|
+
const createEnvironmentHash = require("./webpack/persistentCache/createEnvironmentHash");
|
|
25
22
|
|
|
26
23
|
const postcssNormalize = require("postcss-normalize");
|
|
27
24
|
|
|
@@ -51,9 +48,6 @@ const appPackageJson = require(paths.appPackageJson);
|
|
|
51
48
|
// Source maps are resource heavy and can cause out of memory issue for large source files.
|
|
52
49
|
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== "false";
|
|
53
50
|
|
|
54
|
-
const webpackDevClientEntry = require.resolve("react-dev-utils/webpackHotDevClient");
|
|
55
|
-
const reactRefreshOverlayEntry = require.resolve("react-dev-utils/refreshOverlayInterop");
|
|
56
|
-
|
|
57
51
|
// Some apps do not need the benefits of saving a web request, so not inlining the chunk
|
|
58
52
|
// makes for a smoother build process.
|
|
59
53
|
const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== "false";
|
|
@@ -63,8 +57,9 @@ const imageInlineSizeLimit = parseInt(process.env.IMAGE_INLINE_SIZE_LIMIT || "10
|
|
|
63
57
|
// Check if TypeScript is setup
|
|
64
58
|
const useTypeScript = fs.existsSync(paths.appTsConfig);
|
|
65
59
|
|
|
66
|
-
//
|
|
67
|
-
|
|
60
|
+
// CI runners are memory-capped containers with a throwaway filesystem, so webpack 5
|
|
61
|
+
// defaults that assume a long-lived dev machine work against us there.
|
|
62
|
+
const isCI = process.env.CI === "true";
|
|
68
63
|
|
|
69
64
|
// style files regexes
|
|
70
65
|
const cssRegex = /\.css$/;
|
|
@@ -115,7 +110,9 @@ module.exports = function (webpackEnv) {
|
|
|
115
110
|
},
|
|
116
111
|
{
|
|
117
112
|
loader: require.resolve("css-loader"),
|
|
118
|
-
options:
|
|
113
|
+
options: {
|
|
114
|
+
...cssOptions,
|
|
115
|
+
},
|
|
119
116
|
},
|
|
120
117
|
{
|
|
121
118
|
// Options for PostCSS as we reference these options twice
|
|
@@ -123,26 +120,23 @@ module.exports = function (webpackEnv) {
|
|
|
123
120
|
// package.json
|
|
124
121
|
loader: require.resolve("postcss-loader"),
|
|
125
122
|
options: {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// which in turn let's users customize the target behavior as per their needs.
|
|
144
|
-
postcssNormalize(),
|
|
145
|
-
],
|
|
123
|
+
postcssOptions: {
|
|
124
|
+
plugins: [
|
|
125
|
+
require("postcss-flexbugs-fixes"),
|
|
126
|
+
require("postcss-preset-env")({
|
|
127
|
+
autoprefixer: {
|
|
128
|
+
flexbox: "no-2009",
|
|
129
|
+
},
|
|
130
|
+
stage: 3,
|
|
131
|
+
}),
|
|
132
|
+
// PostCSS plugins from components.
|
|
133
|
+
...postcssConfigPlugins,
|
|
134
|
+
// Adds PostCSS Normalize as the reset css with default options,
|
|
135
|
+
// so that it honors browserslist config in package.json.
|
|
136
|
+
// postcss-preset-env 6 does not bundle normalize, so we keep it.
|
|
137
|
+
postcssNormalize(),
|
|
138
|
+
],
|
|
139
|
+
},
|
|
146
140
|
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
147
141
|
},
|
|
148
142
|
},
|
|
@@ -160,7 +154,8 @@ module.exports = function (webpackEnv) {
|
|
|
160
154
|
{
|
|
161
155
|
loader: require.resolve(preProcessor),
|
|
162
156
|
options: {
|
|
163
|
-
|
|
157
|
+
api: "modern-compiler",
|
|
158
|
+
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
164
159
|
...preProcessorOptions,
|
|
165
160
|
},
|
|
166
161
|
},
|
|
@@ -180,31 +175,7 @@ module.exports = function (webpackEnv) {
|
|
|
180
175
|
: isEnvDevelopment && "cheap-module-source-map",
|
|
181
176
|
// These are the "entry points" to our application.
|
|
182
177
|
// This means they will be the "root" imports that are included in JS bundle.
|
|
183
|
-
entry:
|
|
184
|
-
isEnvDevelopment && !shouldUseReactRefresh
|
|
185
|
-
? [
|
|
186
|
-
// Include an alternative client for WebpackDevServer. A client's job is to
|
|
187
|
-
// connect to WebpackDevServer by a socket and get notified about changes.
|
|
188
|
-
// When you save a file, the client will either apply hot updates (in case
|
|
189
|
-
// of CSS changes), or refresh the page (in case of JS changes). When you
|
|
190
|
-
// make a syntax error, this client will display a syntax error overlay.
|
|
191
|
-
// Note: instead of the default WebpackDevServer client, we use a custom one
|
|
192
|
-
// to bring better experience for Create React App users. You can replace
|
|
193
|
-
// the line below with these two lines if you prefer the stock client:
|
|
194
|
-
//
|
|
195
|
-
// require.resolve('webpack-dev-server/client') + '?/',
|
|
196
|
-
// require.resolve('webpack/hot/dev-server'),
|
|
197
|
-
//
|
|
198
|
-
// When using the experimental react-refresh integration,
|
|
199
|
-
// the webpack plugin takes care of injecting the dev client for us.
|
|
200
|
-
webpackDevClientEntry,
|
|
201
|
-
// Finally, this is your app's code:
|
|
202
|
-
paths.appIndexJs,
|
|
203
|
-
// We include the app code last so that if there is a runtime error during
|
|
204
|
-
// initialization, it doesn't blow up the WebpackDevServer client, and
|
|
205
|
-
// changing JS code would still trigger a refresh.
|
|
206
|
-
]
|
|
207
|
-
: paths.appIndexJs,
|
|
178
|
+
entry: paths.appIndexJs,
|
|
208
179
|
output: {
|
|
209
180
|
// The build folder.
|
|
210
181
|
path: isEnvProduction ? paths.appBuild : undefined,
|
|
@@ -212,13 +183,12 @@ module.exports = function (webpackEnv) {
|
|
|
212
183
|
pathinfo: isEnvDevelopment,
|
|
213
184
|
// There will be one main bundle, and one file per asynchronous chunk.
|
|
214
185
|
// In development, it does not produce real files.
|
|
215
|
-
filename: isEnvProduction ? "static/js/[name].[contenthash:8].js" : isEnvDevelopment && "static/js/
|
|
216
|
-
// TODO: remove this when upgrading to webpack 5
|
|
217
|
-
futureEmitAssets: true,
|
|
186
|
+
filename: isEnvProduction ? "static/js/[name].[contenthash:8].js" : isEnvDevelopment && "static/js/[name].js",
|
|
218
187
|
// There are also additional JS chunk files if you use code splitting.
|
|
219
188
|
chunkFilename: isEnvProduction
|
|
220
189
|
? "static/js/[name].[contenthash:8].chunk.js"
|
|
221
190
|
: isEnvDevelopment && "static/js/[name].chunk.js",
|
|
191
|
+
assetModuleFilename: "static/media/[name].[contenthash:8][ext]",
|
|
222
192
|
// webpack uses `publicPath` to determine where the app is being served from.
|
|
223
193
|
// It requires a trailing slash, or the file assets will get an incorrect path.
|
|
224
194
|
// We inferred the "public path" (such as / or /my-project) from homepage.
|
|
@@ -229,16 +199,40 @@ module.exports = function (webpackEnv) {
|
|
|
229
199
|
: isEnvDevelopment && ((info) => path.resolve(info.absoluteResourcePath).replace(/\\/g, "/")),
|
|
230
200
|
// Prevents conflicts when multiple webpack runtimes (from different apps)
|
|
231
201
|
// are used on the same page.
|
|
232
|
-
|
|
202
|
+
chunkLoadingGlobal: `webpackJsonp${appPackageJson.name}`,
|
|
233
203
|
// this defaults to 'window', but by setting it to 'this' then
|
|
234
204
|
// module chunks which are built will work in web workers as well.
|
|
235
205
|
globalObject: "this",
|
|
206
|
+
// Node.js 17+ (OpenSSL 3.0) dropped MD4, webpack 5's default hash function.
|
|
207
|
+
// xxhash64 avoids the `digital envelope routines::unsupported` error and lets
|
|
208
|
+
// us drop the `--openssl-legacy-provider` workaround.
|
|
209
|
+
hashFunction: "xxhash64",
|
|
236
210
|
},
|
|
211
|
+
// The persistent cache pays off on a dev machine, but CI installs node_modules
|
|
212
|
+
// from scratch on every run: the ~640 MB pack is built, held in memory to be
|
|
213
|
+
// serialized and then thrown away, for zero reuse.
|
|
214
|
+
cache: isCI
|
|
215
|
+
? false
|
|
216
|
+
: {
|
|
217
|
+
type: "filesystem",
|
|
218
|
+
version: createEnvironmentHash(env.raw),
|
|
219
|
+
cacheDirectory: paths.appWebpackCache,
|
|
220
|
+
store: "pack",
|
|
221
|
+
buildDependencies: {
|
|
222
|
+
defaultWebpack: ["webpack/lib/"],
|
|
223
|
+
config: [__filename],
|
|
224
|
+
tsconfig: [paths.appTsConfig].filter(Boolean),
|
|
225
|
+
},
|
|
226
|
+
},
|
|
237
227
|
optimization: {
|
|
238
228
|
minimize: isEnvProduction,
|
|
239
229
|
minimizer: [
|
|
240
230
|
// This is only used in production mode
|
|
241
231
|
new TerserPlugin({
|
|
232
|
+
// Inside a container os.cpus() reports the host's cores, so the default
|
|
233
|
+
// (cores - 1) forks far more workers than the pod can feed, each one a
|
|
234
|
+
// Node process inheriting NODE_OPTIONS' heap ceiling.
|
|
235
|
+
parallel: isCI ? 2 : true,
|
|
242
236
|
terserOptions: {
|
|
243
237
|
parse: {
|
|
244
238
|
// We want terser to parse ecma 8 code. However, we don't want it
|
|
@@ -276,34 +270,15 @@ module.exports = function (webpackEnv) {
|
|
|
276
270
|
ascii_only: true,
|
|
277
271
|
},
|
|
278
272
|
},
|
|
279
|
-
sourceMap: shouldUseSourceMap,
|
|
280
273
|
}),
|
|
281
274
|
// This is only used in production mode
|
|
282
|
-
new
|
|
283
|
-
cssProcessorOptions: {
|
|
284
|
-
parser: safePostCssParser,
|
|
285
|
-
map: shouldUseSourceMap
|
|
286
|
-
? {
|
|
287
|
-
// `inline: false` forces the sourcemap to be output into a
|
|
288
|
-
// separate file
|
|
289
|
-
inline: false,
|
|
290
|
-
// `annotation: true` appends the sourceMappingURL to the end of
|
|
291
|
-
// the css file, helping the browser find the sourcemap
|
|
292
|
-
annotation: true,
|
|
293
|
-
}
|
|
294
|
-
: false,
|
|
295
|
-
},
|
|
296
|
-
cssProcessorPluginOptions: {
|
|
297
|
-
preset: ["default", { minifyFontValues: { removeQuotes: false } }],
|
|
298
|
-
},
|
|
299
|
-
}),
|
|
275
|
+
new CssMinimizerPlugin(),
|
|
300
276
|
],
|
|
301
277
|
// Automatically split vendor and commons
|
|
302
278
|
// https://twitter.com/wSokra/status/969633336732905474
|
|
303
279
|
// https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
|
|
304
280
|
splitChunks: {
|
|
305
281
|
chunks: "all",
|
|
306
|
-
name: isEnvDevelopment,
|
|
307
282
|
},
|
|
308
283
|
// Keep the runtime chunk separated to enable long term caching
|
|
309
284
|
// https://twitter.com/wSokra/status/969679223278505985
|
|
@@ -339,49 +314,52 @@ module.exports = function (webpackEnv) {
|
|
|
339
314
|
...(modules.webpackAliases || {}),
|
|
340
315
|
...projectAliases,
|
|
341
316
|
},
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
317
|
+
// Stub Node builtins that have no browser equivalent (webpack 4 mocked these via
|
|
318
|
+
// its old core-module block: module, dgram, dns, fs, http2, net, tls, child_process).
|
|
319
|
+
// Everything with a browser polyfill (buffer, stream, crypto, http, https, zlib,
|
|
320
|
+
// util, process, ...) is provided by NodePolyfillPlugin, restoring webpack 4's
|
|
321
|
+
// auto-polyfill behaviour so legacy client instances keep building.
|
|
322
|
+
fallback: {
|
|
323
|
+
fs: false,
|
|
324
|
+
net: false,
|
|
325
|
+
tls: false,
|
|
326
|
+
child_process: false,
|
|
327
|
+
dns: false,
|
|
328
|
+
http2: false,
|
|
329
|
+
module: false,
|
|
330
|
+
dgram: false,
|
|
331
|
+
},
|
|
354
332
|
},
|
|
355
333
|
module: {
|
|
356
334
|
strictExportPresence: true,
|
|
357
335
|
rules: [
|
|
358
|
-
// Disable require.ensure as it's not a standard language feature.
|
|
359
|
-
{ parser: { requireEnsure: false } },
|
|
360
336
|
{
|
|
361
337
|
// "oneOf" will traverse all following loaders until one will
|
|
362
338
|
// match the requirements. When no loader matches it will fall
|
|
363
|
-
// back to the "
|
|
339
|
+
// back to the "resource" asset module at the end of the loader list.
|
|
364
340
|
oneOf: [
|
|
365
341
|
// TODO: Merge this config once `image/avif` is in the mime-db
|
|
366
342
|
// https://github.com/jshttp/mime-db
|
|
367
343
|
{
|
|
368
344
|
test: [/\.avif$/],
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
345
|
+
type: "asset",
|
|
346
|
+
mimetype: "image/avif",
|
|
347
|
+
parser: {
|
|
348
|
+
dataUrlCondition: {
|
|
349
|
+
maxSize: imageInlineSizeLimit,
|
|
350
|
+
},
|
|
374
351
|
},
|
|
375
352
|
},
|
|
376
|
-
// "
|
|
353
|
+
// "asset" loader works like "file" loader except that it embeds assets
|
|
377
354
|
// smaller than specified limit in bytes as data URLs to avoid requests.
|
|
378
355
|
// A missing `test` is equivalent to a match.
|
|
379
356
|
{
|
|
380
357
|
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
358
|
+
type: "asset",
|
|
359
|
+
parser: {
|
|
360
|
+
dataUrlCondition: {
|
|
361
|
+
maxSize: imageInlineSizeLimit,
|
|
362
|
+
},
|
|
385
363
|
},
|
|
386
364
|
},
|
|
387
365
|
// Process application JS with Babel.
|
|
@@ -475,6 +453,14 @@ module.exports = function (webpackEnv) {
|
|
|
475
453
|
importLoaders: 1,
|
|
476
454
|
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
477
455
|
modules: {
|
|
456
|
+
// css-loader v6 defaults `esModule: true`, so `import * as styles`
|
|
457
|
+
// only sees locals as named exports when `namedExport` is on.
|
|
458
|
+
// griddo-components relies on `import * as styles` heavily.
|
|
459
|
+
namedExport: true,
|
|
460
|
+
// `dashesOnly` converts only hyphenated names (foo-bar -> fooBar) so
|
|
461
|
+
// `composes: heading-sm` works, while leaving JS-reserved names such as
|
|
462
|
+
// `@keyframes _in` untouched (camelCaseOnly would break those).
|
|
463
|
+
exportLocalsConvention: "dashesOnly",
|
|
478
464
|
getLocalIdent: getCSSModuleLocalIdent,
|
|
479
465
|
},
|
|
480
466
|
}),
|
|
@@ -507,6 +493,8 @@ module.exports = function (webpackEnv) {
|
|
|
507
493
|
importLoaders: 3,
|
|
508
494
|
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
509
495
|
modules: {
|
|
496
|
+
namedExport: true,
|
|
497
|
+
exportLocalsConvention: "dashesOnly",
|
|
510
498
|
getLocalIdent: getCSSModuleLocalIdent,
|
|
511
499
|
},
|
|
512
500
|
},
|
|
@@ -515,30 +503,20 @@ module.exports = function (webpackEnv) {
|
|
|
515
503
|
},
|
|
516
504
|
{
|
|
517
505
|
test: /\.(woff|woff2)$/,
|
|
518
|
-
|
|
506
|
+
type: "asset/resource",
|
|
519
507
|
},
|
|
520
508
|
{
|
|
521
509
|
test: /\.svg$/,
|
|
522
510
|
use: ["@svgr/webpack"],
|
|
523
511
|
},
|
|
524
|
-
//
|
|
525
|
-
//
|
|
526
|
-
// In production, they would get copied to the `build` folder.
|
|
527
|
-
// This loader doesn't use a "test" so it will catch all modules
|
|
528
|
-
// that fall through the other loaders.
|
|
512
|
+
// Catch-all: anything not handled above is emitted as a separate file.
|
|
513
|
+
// This replaces the old file-loader catch-all.
|
|
529
514
|
{
|
|
530
|
-
loader: require.resolve("file-loader"),
|
|
531
|
-
// Exclude `js` files to keep "css" loader working as it injects
|
|
532
|
-
// its runtime that would otherwise be processed through "file" loader.
|
|
533
|
-
// Also exclude `html` and `json` extensions so they get processed
|
|
534
|
-
// by webpacks internal loaders.
|
|
535
515
|
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
|
|
536
|
-
|
|
537
|
-
name: "static/media/[name].[hash:8].[ext]",
|
|
538
|
-
},
|
|
516
|
+
type: "asset/resource",
|
|
539
517
|
},
|
|
540
518
|
// ** STOP ** Are you adding a new loader?
|
|
541
|
-
// Make sure to add the new loader(s) before the "
|
|
519
|
+
// Make sure to add the new loader(s) before the "asset/resource" catch-all.
|
|
542
520
|
],
|
|
543
521
|
},
|
|
544
522
|
{
|
|
@@ -549,6 +527,12 @@ module.exports = function (webpackEnv) {
|
|
|
549
527
|
],
|
|
550
528
|
},
|
|
551
529
|
plugins: [
|
|
530
|
+
// Restore webpack 4's Node core-module handling for browser bundles. Clients run
|
|
531
|
+
// `griddo build` (this config) against their own instance, so this guards legacy
|
|
532
|
+
// instances against "Module not found" for Node builtins that webpack 5 no longer
|
|
533
|
+
// polyfills automatically. Browser-polyfillable builtins are provided here; the
|
|
534
|
+
// server-only ones are stubbed via resolve.fallback above.
|
|
535
|
+
new NodePolyfillPlugin(),
|
|
552
536
|
// Generates an `index.html` file with the <script> injected.
|
|
553
537
|
new HtmlWebpackPlugin(
|
|
554
538
|
Object.assign(
|
|
@@ -594,32 +578,23 @@ module.exports = function (webpackEnv) {
|
|
|
594
578
|
// during a production build.
|
|
595
579
|
// Otherwise React will be compiled in the very slow development mode.
|
|
596
580
|
new webpack.DefinePlugin(env.stringified),
|
|
597
|
-
//
|
|
598
|
-
|
|
599
|
-
//
|
|
581
|
+
// HMR is handled by WebpackDevServer 4 (`hot: true` in webpackDevServer.config.js),
|
|
582
|
+
// which registers HotModuleReplacementPlugin automatically. We no longer add it
|
|
583
|
+
// manually to avoid a duplicate-plugin instance.
|
|
584
|
+
// Experimental hot reloading for React (Fast Refresh).
|
|
600
585
|
// https://github.com/facebook/react/tree/master/packages/react-refresh
|
|
601
586
|
isEnvDevelopment &&
|
|
602
587
|
shouldUseReactRefresh &&
|
|
603
588
|
new ReactRefreshWebpackPlugin({
|
|
604
|
-
overlay
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
module: reactRefreshOverlayEntry,
|
|
609
|
-
// Since we ship a custom dev client and overlay integration,
|
|
610
|
-
// the bundled socket handling logic can be eliminated.
|
|
611
|
-
sockIntegration: false,
|
|
612
|
-
},
|
|
589
|
+
// The error overlay is served by WebpackDevServer 4's native client
|
|
590
|
+
// (see `client.overlay` in webpackDevServer.config.js). Disable the
|
|
591
|
+
// Fast Refresh plugin overlay to avoid two overlays fighting.
|
|
592
|
+
overlay: false,
|
|
613
593
|
}),
|
|
614
594
|
// Watcher doesn't work well if you mistype casing in a path so we use
|
|
615
595
|
// a plugin that prints an error when you attempt to do this.
|
|
616
596
|
// See https://github.com/facebook/create-react-app/issues/240
|
|
617
597
|
isEnvDevelopment && new CaseSensitivePathsPlugin(),
|
|
618
|
-
// If you require a missing module and then `npm install` it, you still have
|
|
619
|
-
// to restart the development server for webpack to discover it. This plugin
|
|
620
|
-
// makes the discovery automatic so you don't have to restart.
|
|
621
|
-
// See https://github.com/facebook/create-react-app/issues/186
|
|
622
|
-
isEnvDevelopment && new WatchMissingNodeModulesPlugin(paths.appNodeModules),
|
|
623
598
|
isEnvProduction &&
|
|
624
599
|
new MiniCssExtractPlugin({
|
|
625
600
|
// Options similar to the same options in webpackOptions.output
|
|
@@ -633,7 +608,7 @@ module.exports = function (webpackEnv) {
|
|
|
633
608
|
// `index.html`
|
|
634
609
|
// - "entrypoints" key: Array of files which are included in `index.html`,
|
|
635
610
|
// can be used to reconstruct the HTML if necessary
|
|
636
|
-
new
|
|
611
|
+
new WebpackManifestPlugin({
|
|
637
612
|
fileName: "asset-manifest.json",
|
|
638
613
|
publicPath: paths.publicUrlOrPath,
|
|
639
614
|
generate: (seed, files, entrypoints) => {
|
|
@@ -654,60 +629,49 @@ module.exports = function (webpackEnv) {
|
|
|
654
629
|
// solution that requires the user to opt into importing specific locales.
|
|
655
630
|
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
|
|
656
631
|
// You can remove this if you don't use Moment.js:
|
|
657
|
-
new webpack.IgnorePlugin(
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
fs.existsSync(swSrc) &&
|
|
662
|
-
new WorkboxWebpackPlugin.InjectManifest({
|
|
663
|
-
swSrc,
|
|
664
|
-
dontCacheBustURLsMatching: /\.[0-9a-f]{8}\./,
|
|
665
|
-
exclude: [/\.map$/, /asset-manifest\.json$/, /LICENSE/],
|
|
666
|
-
// Bump up the default maximum size (2mb) that's precached,
|
|
667
|
-
// to make lazy-loading failure scenarios less likely.
|
|
668
|
-
// See https://github.com/cra-template/pwa/issues/13#issuecomment-722667270
|
|
669
|
-
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
|
|
670
|
-
}),
|
|
632
|
+
new webpack.IgnorePlugin({
|
|
633
|
+
resourceRegExp: /^\.\/locale$/,
|
|
634
|
+
contextRegExp: /moment$/,
|
|
635
|
+
}),
|
|
671
636
|
// TypeScript type checking
|
|
672
637
|
useTypeScript &&
|
|
673
638
|
new ForkTsCheckerWebpackPlugin({
|
|
674
|
-
typescript: resolve.sync("typescript", {
|
|
675
|
-
basedir: paths.appNodeModules,
|
|
676
|
-
}),
|
|
677
639
|
async: isEnvDevelopment,
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
640
|
+
typescript: {
|
|
641
|
+
typescriptPath: resolve.sync("typescript", {
|
|
642
|
+
basedir: paths.appNodeModules,
|
|
643
|
+
}),
|
|
644
|
+
configOverwrite: {
|
|
645
|
+
compilerOptions: {
|
|
646
|
+
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
647
|
+
skipLibCheck: true,
|
|
648
|
+
inlineSourceMap: false,
|
|
649
|
+
declarationMap: false,
|
|
650
|
+
noEmit: true,
|
|
651
|
+
incremental: true,
|
|
652
|
+
tsBuildInfoFile: paths.appTsBuildInfoFile,
|
|
653
|
+
},
|
|
654
|
+
},
|
|
655
|
+
context: paths.appPath,
|
|
656
|
+
diagnosticOptions: {
|
|
657
|
+
syntactic: true,
|
|
658
|
+
},
|
|
659
|
+
mode: "write-references",
|
|
660
|
+
},
|
|
661
|
+
issue: {
|
|
662
|
+
include: [{ file: "../**/src/**/*.{ts,tsx}" }, { file: "**/src/**/*.{ts,tsx}" }],
|
|
663
|
+
exclude: [
|
|
664
|
+
{ file: "**/src/**/__tests__/**" },
|
|
665
|
+
{ file: "**/src/**/?(*.){spec|test}.*" },
|
|
666
|
+
{ file: "**/src/setupProxy.*" },
|
|
667
|
+
{ file: "**/src/setupTests.*" },
|
|
668
|
+
],
|
|
669
|
+
},
|
|
670
|
+
logger: {
|
|
671
|
+
infrastructure: "silent",
|
|
672
|
+
},
|
|
697
673
|
}),
|
|
698
674
|
].filter(Boolean),
|
|
699
|
-
// Some libraries import Node modules but don't use them in the browser.
|
|
700
|
-
// Tell webpack to provide empty mocks for them so importing them works.
|
|
701
|
-
node: {
|
|
702
|
-
module: "empty",
|
|
703
|
-
dgram: "empty",
|
|
704
|
-
dns: "mock",
|
|
705
|
-
fs: "empty",
|
|
706
|
-
http2: "empty",
|
|
707
|
-
net: "empty",
|
|
708
|
-
tls: "empty",
|
|
709
|
-
child_process: "empty",
|
|
710
|
-
},
|
|
711
675
|
// Turn off performance processing because we utilize
|
|
712
676
|
// our own hints via the FileSizeReporter
|
|
713
677
|
performance: false,
|