@griddo/ax 12.2.2 → 12.2.3-rc.1
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 +180 -189
- package/config/webpackDevServer.config.js +63 -93
- package/config/webpackSchemas.config.js +6 -1
- package/package.json +20 -26
- package/scripts/build.js +4 -0
- package/scripts/start.js +38 -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
|
},
|
|
@@ -171,6 +166,11 @@ module.exports = function (webpackEnv) {
|
|
|
171
166
|
|
|
172
167
|
return {
|
|
173
168
|
mode: isEnvProduction ? "production" : isEnvDevelopment && "development",
|
|
169
|
+
// Pin the target instead of letting webpack 5 derive it from the client
|
|
170
|
+
// project's browserslist: queries like "maintained node versions" (common
|
|
171
|
+
// in Gatsby-rendered projects) drop the `document` capability and switch
|
|
172
|
+
// chunks to ESM format, which breaks the editor's classic script tags.
|
|
173
|
+
target: ["web", "es2017"],
|
|
174
174
|
// Stop compilation early in production
|
|
175
175
|
bail: isEnvProduction,
|
|
176
176
|
devtool: isEnvProduction
|
|
@@ -180,31 +180,7 @@ module.exports = function (webpackEnv) {
|
|
|
180
180
|
: isEnvDevelopment && "cheap-module-source-map",
|
|
181
181
|
// These are the "entry points" to our application.
|
|
182
182
|
// 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,
|
|
183
|
+
entry: paths.appIndexJs,
|
|
208
184
|
output: {
|
|
209
185
|
// The build folder.
|
|
210
186
|
path: isEnvProduction ? paths.appBuild : undefined,
|
|
@@ -212,13 +188,12 @@ module.exports = function (webpackEnv) {
|
|
|
212
188
|
pathinfo: isEnvDevelopment,
|
|
213
189
|
// There will be one main bundle, and one file per asynchronous chunk.
|
|
214
190
|
// 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,
|
|
191
|
+
filename: isEnvProduction ? "static/js/[name].[contenthash:8].js" : isEnvDevelopment && "static/js/[name].js",
|
|
218
192
|
// There are also additional JS chunk files if you use code splitting.
|
|
219
193
|
chunkFilename: isEnvProduction
|
|
220
194
|
? "static/js/[name].[contenthash:8].chunk.js"
|
|
221
195
|
: isEnvDevelopment && "static/js/[name].chunk.js",
|
|
196
|
+
assetModuleFilename: "static/media/[name].[contenthash:8][ext]",
|
|
222
197
|
// webpack uses `publicPath` to determine where the app is being served from.
|
|
223
198
|
// It requires a trailing slash, or the file assets will get an incorrect path.
|
|
224
199
|
// We inferred the "public path" (such as / or /my-project) from homepage.
|
|
@@ -229,16 +204,40 @@ module.exports = function (webpackEnv) {
|
|
|
229
204
|
: isEnvDevelopment && ((info) => path.resolve(info.absoluteResourcePath).replace(/\\/g, "/")),
|
|
230
205
|
// Prevents conflicts when multiple webpack runtimes (from different apps)
|
|
231
206
|
// are used on the same page.
|
|
232
|
-
|
|
207
|
+
chunkLoadingGlobal: `webpackJsonp${appPackageJson.name}`,
|
|
233
208
|
// this defaults to 'window', but by setting it to 'this' then
|
|
234
209
|
// module chunks which are built will work in web workers as well.
|
|
235
210
|
globalObject: "this",
|
|
211
|
+
// Node.js 17+ (OpenSSL 3.0) dropped MD4, webpack 5's default hash function.
|
|
212
|
+
// xxhash64 avoids the `digital envelope routines::unsupported` error and lets
|
|
213
|
+
// us drop the `--openssl-legacy-provider` workaround.
|
|
214
|
+
hashFunction: "xxhash64",
|
|
236
215
|
},
|
|
216
|
+
// The persistent cache pays off on a dev machine, but CI installs node_modules
|
|
217
|
+
// from scratch on every run: the ~640 MB pack is built, held in memory to be
|
|
218
|
+
// serialized and then thrown away, for zero reuse.
|
|
219
|
+
cache: isCI
|
|
220
|
+
? false
|
|
221
|
+
: {
|
|
222
|
+
type: "filesystem",
|
|
223
|
+
version: createEnvironmentHash(env.raw),
|
|
224
|
+
cacheDirectory: paths.appWebpackCache,
|
|
225
|
+
store: "pack",
|
|
226
|
+
buildDependencies: {
|
|
227
|
+
defaultWebpack: ["webpack/lib/"],
|
|
228
|
+
config: [__filename],
|
|
229
|
+
tsconfig: [paths.appTsConfig].filter(Boolean),
|
|
230
|
+
},
|
|
231
|
+
},
|
|
237
232
|
optimization: {
|
|
238
233
|
minimize: isEnvProduction,
|
|
239
234
|
minimizer: [
|
|
240
235
|
// This is only used in production mode
|
|
241
236
|
new TerserPlugin({
|
|
237
|
+
// Inside a container os.cpus() reports the host's cores, so the default
|
|
238
|
+
// (cores - 1) forks far more workers than the pod can feed, each one a
|
|
239
|
+
// Node process inheriting NODE_OPTIONS' heap ceiling.
|
|
240
|
+
parallel: isCI ? 2 : true,
|
|
242
241
|
terserOptions: {
|
|
243
242
|
parse: {
|
|
244
243
|
// We want terser to parse ecma 8 code. However, we don't want it
|
|
@@ -276,34 +275,15 @@ module.exports = function (webpackEnv) {
|
|
|
276
275
|
ascii_only: true,
|
|
277
276
|
},
|
|
278
277
|
},
|
|
279
|
-
sourceMap: shouldUseSourceMap,
|
|
280
278
|
}),
|
|
281
279
|
// 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
|
-
}),
|
|
280
|
+
new CssMinimizerPlugin(),
|
|
300
281
|
],
|
|
301
282
|
// Automatically split vendor and commons
|
|
302
283
|
// https://twitter.com/wSokra/status/969633336732905474
|
|
303
284
|
// https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
|
|
304
285
|
splitChunks: {
|
|
305
286
|
chunks: "all",
|
|
306
|
-
name: isEnvDevelopment,
|
|
307
287
|
},
|
|
308
288
|
// Keep the runtime chunk separated to enable long term caching
|
|
309
289
|
// https://twitter.com/wSokra/status/969679223278505985
|
|
@@ -339,49 +319,60 @@ module.exports = function (webpackEnv) {
|
|
|
339
319
|
...(modules.webpackAliases || {}),
|
|
340
320
|
...projectAliases,
|
|
341
321
|
},
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
322
|
+
// Stub Node builtins that have no browser equivalent (webpack 4 mocked these via
|
|
323
|
+
// its old core-module block: module, dgram, dns, fs, http2, net, tls, child_process).
|
|
324
|
+
// Everything with a browser polyfill (buffer, stream, crypto, http, https, zlib,
|
|
325
|
+
// util, process, ...) is provided by NodePolyfillPlugin, restoring webpack 4's
|
|
326
|
+
// auto-polyfill behaviour so legacy client instances keep building.
|
|
327
|
+
fallback: {
|
|
328
|
+
fs: false,
|
|
329
|
+
net: false,
|
|
330
|
+
tls: false,
|
|
331
|
+
child_process: false,
|
|
332
|
+
dns: false,
|
|
333
|
+
http2: false,
|
|
334
|
+
module: false,
|
|
335
|
+
dgram: false,
|
|
336
|
+
},
|
|
354
337
|
},
|
|
355
338
|
module: {
|
|
356
|
-
|
|
339
|
+
// Missing exports must stay non-blocking: webpack 4's CJS css-loader
|
|
340
|
+
// never validated CSS-module classes, so client projects accumulated
|
|
341
|
+
// references to classes that don't exist. With webpack 5 named exports
|
|
342
|
+
// those would all become compile errors and block adoption.
|
|
343
|
+
parser: {
|
|
344
|
+
javascript: {
|
|
345
|
+
exportsPresence: "warn",
|
|
346
|
+
},
|
|
347
|
+
},
|
|
357
348
|
rules: [
|
|
358
|
-
// Disable require.ensure as it's not a standard language feature.
|
|
359
|
-
{ parser: { requireEnsure: false } },
|
|
360
349
|
{
|
|
361
350
|
// "oneOf" will traverse all following loaders until one will
|
|
362
351
|
// match the requirements. When no loader matches it will fall
|
|
363
|
-
// back to the "
|
|
352
|
+
// back to the "resource" asset module at the end of the loader list.
|
|
364
353
|
oneOf: [
|
|
365
354
|
// TODO: Merge this config once `image/avif` is in the mime-db
|
|
366
355
|
// https://github.com/jshttp/mime-db
|
|
367
356
|
{
|
|
368
357
|
test: [/\.avif$/],
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
358
|
+
type: "asset",
|
|
359
|
+
mimetype: "image/avif",
|
|
360
|
+
parser: {
|
|
361
|
+
dataUrlCondition: {
|
|
362
|
+
maxSize: imageInlineSizeLimit,
|
|
363
|
+
},
|
|
374
364
|
},
|
|
375
365
|
},
|
|
376
|
-
// "
|
|
366
|
+
// "asset" loader works like "file" loader except that it embeds assets
|
|
377
367
|
// smaller than specified limit in bytes as data URLs to avoid requests.
|
|
378
368
|
// A missing `test` is equivalent to a match.
|
|
379
369
|
{
|
|
380
370
|
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
371
|
+
type: "asset",
|
|
372
|
+
parser: {
|
|
373
|
+
dataUrlCondition: {
|
|
374
|
+
maxSize: imageInlineSizeLimit,
|
|
375
|
+
},
|
|
385
376
|
},
|
|
386
377
|
},
|
|
387
378
|
// Process application JS with Babel.
|
|
@@ -475,6 +466,14 @@ module.exports = function (webpackEnv) {
|
|
|
475
466
|
importLoaders: 1,
|
|
476
467
|
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
477
468
|
modules: {
|
|
469
|
+
// css-loader v6 defaults `esModule: true`, so `import * as styles`
|
|
470
|
+
// only sees locals as named exports when `namedExport` is on.
|
|
471
|
+
// griddo-components relies on `import * as styles` heavily.
|
|
472
|
+
namedExport: true,
|
|
473
|
+
// `dashesOnly` converts only hyphenated names (foo-bar -> fooBar) so
|
|
474
|
+
// `composes: heading-sm` works, while leaving JS-reserved names such as
|
|
475
|
+
// `@keyframes _in` untouched (camelCaseOnly would break those).
|
|
476
|
+
exportLocalsConvention: "dashesOnly",
|
|
478
477
|
getLocalIdent: getCSSModuleLocalIdent,
|
|
479
478
|
},
|
|
480
479
|
}),
|
|
@@ -507,6 +506,8 @@ module.exports = function (webpackEnv) {
|
|
|
507
506
|
importLoaders: 3,
|
|
508
507
|
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
509
508
|
modules: {
|
|
509
|
+
namedExport: true,
|
|
510
|
+
exportLocalsConvention: "dashesOnly",
|
|
510
511
|
getLocalIdent: getCSSModuleLocalIdent,
|
|
511
512
|
},
|
|
512
513
|
},
|
|
@@ -515,30 +516,20 @@ module.exports = function (webpackEnv) {
|
|
|
515
516
|
},
|
|
516
517
|
{
|
|
517
518
|
test: /\.(woff|woff2)$/,
|
|
518
|
-
|
|
519
|
+
type: "asset/resource",
|
|
519
520
|
},
|
|
520
521
|
{
|
|
521
522
|
test: /\.svg$/,
|
|
522
523
|
use: ["@svgr/webpack"],
|
|
523
524
|
},
|
|
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.
|
|
525
|
+
// Catch-all: anything not handled above is emitted as a separate file.
|
|
526
|
+
// This replaces the old file-loader catch-all.
|
|
529
527
|
{
|
|
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
528
|
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
|
|
536
|
-
|
|
537
|
-
name: "static/media/[name].[hash:8].[ext]",
|
|
538
|
-
},
|
|
529
|
+
type: "asset/resource",
|
|
539
530
|
},
|
|
540
531
|
// ** STOP ** Are you adding a new loader?
|
|
541
|
-
// Make sure to add the new loader(s) before the "
|
|
532
|
+
// Make sure to add the new loader(s) before the "asset/resource" catch-all.
|
|
542
533
|
],
|
|
543
534
|
},
|
|
544
535
|
{
|
|
@@ -549,6 +540,12 @@ module.exports = function (webpackEnv) {
|
|
|
549
540
|
],
|
|
550
541
|
},
|
|
551
542
|
plugins: [
|
|
543
|
+
// Restore webpack 4's Node core-module handling for browser bundles. Clients run
|
|
544
|
+
// `griddo build` (this config) against their own instance, so this guards legacy
|
|
545
|
+
// instances against "Module not found" for Node builtins that webpack 5 no longer
|
|
546
|
+
// polyfills automatically. Browser-polyfillable builtins are provided here; the
|
|
547
|
+
// server-only ones are stubbed via resolve.fallback above.
|
|
548
|
+
new NodePolyfillPlugin(),
|
|
552
549
|
// Generates an `index.html` file with the <script> injected.
|
|
553
550
|
new HtmlWebpackPlugin(
|
|
554
551
|
Object.assign(
|
|
@@ -594,32 +591,23 @@ module.exports = function (webpackEnv) {
|
|
|
594
591
|
// during a production build.
|
|
595
592
|
// Otherwise React will be compiled in the very slow development mode.
|
|
596
593
|
new webpack.DefinePlugin(env.stringified),
|
|
597
|
-
//
|
|
598
|
-
|
|
599
|
-
//
|
|
594
|
+
// HMR is handled by WebpackDevServer 4 (`hot: true` in webpackDevServer.config.js),
|
|
595
|
+
// which registers HotModuleReplacementPlugin automatically. We no longer add it
|
|
596
|
+
// manually to avoid a duplicate-plugin instance.
|
|
597
|
+
// Experimental hot reloading for React (Fast Refresh).
|
|
600
598
|
// https://github.com/facebook/react/tree/master/packages/react-refresh
|
|
601
599
|
isEnvDevelopment &&
|
|
602
600
|
shouldUseReactRefresh &&
|
|
603
601
|
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
|
-
},
|
|
602
|
+
// The error overlay is served by WebpackDevServer 4's native client
|
|
603
|
+
// (see `client.overlay` in webpackDevServer.config.js). Disable the
|
|
604
|
+
// Fast Refresh plugin overlay to avoid two overlays fighting.
|
|
605
|
+
overlay: false,
|
|
613
606
|
}),
|
|
614
607
|
// Watcher doesn't work well if you mistype casing in a path so we use
|
|
615
608
|
// a plugin that prints an error when you attempt to do this.
|
|
616
609
|
// See https://github.com/facebook/create-react-app/issues/240
|
|
617
610
|
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
611
|
isEnvProduction &&
|
|
624
612
|
new MiniCssExtractPlugin({
|
|
625
613
|
// Options similar to the same options in webpackOptions.output
|
|
@@ -633,7 +621,7 @@ module.exports = function (webpackEnv) {
|
|
|
633
621
|
// `index.html`
|
|
634
622
|
// - "entrypoints" key: Array of files which are included in `index.html`,
|
|
635
623
|
// can be used to reconstruct the HTML if necessary
|
|
636
|
-
new
|
|
624
|
+
new WebpackManifestPlugin({
|
|
637
625
|
fileName: "asset-manifest.json",
|
|
638
626
|
publicPath: paths.publicUrlOrPath,
|
|
639
627
|
generate: (seed, files, entrypoints) => {
|
|
@@ -654,59 +642,62 @@ module.exports = function (webpackEnv) {
|
|
|
654
642
|
// solution that requires the user to opt into importing specific locales.
|
|
655
643
|
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
|
|
656
644
|
// 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
|
-
}),
|
|
645
|
+
new webpack.IgnorePlugin({
|
|
646
|
+
resourceRegExp: /^\.\/locale$/,
|
|
647
|
+
contextRegExp: /moment$/,
|
|
648
|
+
}),
|
|
671
649
|
// TypeScript type checking
|
|
672
650
|
useTypeScript &&
|
|
673
651
|
new ForkTsCheckerWebpackPlugin({
|
|
674
|
-
typescript: resolve.sync("typescript", {
|
|
675
|
-
basedir: paths.appNodeModules,
|
|
676
|
-
}),
|
|
677
652
|
async: isEnvDevelopment,
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
//
|
|
684
|
-
//
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
653
|
+
typescript: {
|
|
654
|
+
typescriptPath: resolve.sync("typescript", {
|
|
655
|
+
basedir: paths.appNodeModules,
|
|
656
|
+
}),
|
|
657
|
+
// Must be an absolute path: fork-ts-checker v6 resolves a relative
|
|
658
|
+
// "tsconfig.json" against the webpack compiler context (the client
|
|
659
|
+
// project cwd), which would pick up the client's tsconfig instead.
|
|
660
|
+
configFile: paths.appTsConfig,
|
|
661
|
+
configOverwrite: {
|
|
662
|
+
compilerOptions: {
|
|
663
|
+
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
|
|
664
|
+
skipLibCheck: true,
|
|
665
|
+
inlineSourceMap: false,
|
|
666
|
+
declarationMap: false,
|
|
667
|
+
noEmit: true,
|
|
668
|
+
incremental: true,
|
|
669
|
+
tsBuildInfoFile: paths.appTsBuildInfoFile,
|
|
670
|
+
},
|
|
671
|
+
},
|
|
672
|
+
context: paths.appPath,
|
|
673
|
+
diagnosticOptions: {
|
|
674
|
+
syntactic: true,
|
|
675
|
+
},
|
|
676
|
+
mode: "write-references",
|
|
677
|
+
},
|
|
678
|
+
issue: {
|
|
679
|
+
include: [{ file: "../**/src/**/*.{ts,tsx}" }, { file: "**/src/**/*.{ts,tsx}" }],
|
|
680
|
+
exclude: [
|
|
681
|
+
{ file: "**/src/**/__tests__/**" },
|
|
682
|
+
{ file: "**/src/**/?(*.)(spec|test).*" },
|
|
683
|
+
{ file: "**/src/setupProxy.*" },
|
|
684
|
+
{ file: "**/src/setupTests.*" },
|
|
685
|
+
],
|
|
686
|
+
},
|
|
687
|
+
logger: {
|
|
688
|
+
infrastructure: "silent",
|
|
689
|
+
// Progress lines ("Files successfully emitted…", "No issues
|
|
690
|
+
// found."). Actual TS errors still reach webpack's compilation
|
|
691
|
+
// and are printed by react-dev-utils.
|
|
692
|
+
issues: "silent",
|
|
693
|
+
},
|
|
697
694
|
}),
|
|
698
695
|
].filter(Boolean),
|
|
699
|
-
//
|
|
700
|
-
//
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
dns: "mock",
|
|
705
|
-
fs: "empty",
|
|
706
|
-
http2: "empty",
|
|
707
|
-
net: "empty",
|
|
708
|
-
tls: "empty",
|
|
709
|
-
child_process: "empty",
|
|
696
|
+
// Silence webpack-dev-middleware's stats dump on every (re)build —
|
|
697
|
+
// webpack 4's dev server did this via `quiet: true`. react-dev-utils
|
|
698
|
+
// still prints the friendly "Compiled successfully" + URLs block.
|
|
699
|
+
infrastructureLogging: {
|
|
700
|
+
level: "none",
|
|
710
701
|
},
|
|
711
702
|
// Turn off performance processing because we utilize
|
|
712
703
|
// our own hints via the FileSizeReporter
|