-
Notifications
You must be signed in to change notification settings - Fork 355
/
createWebpackConfig.ts
773 lines (750 loc) · 27.9 KB
/
createWebpackConfig.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
import OptimizeCssnanoPlugin from "@intervolga/optimize-cssnano-plugin";
import bunyan from "bunyan";
import CaseSensitivePathsPlugin from "case-sensitive-paths-webpack-plugin";
import CompressionPlugin from "compression-webpack-plugin";
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
import HtmlWebpackPlugin from "html-webpack-plugin";
import { identity } from "lodash";
import MiniCssExtractPlugin from "mini-css-extract-plugin";
import path from "path";
import WatchMissingNodeModulesPlugin from "react-dev-utils/WatchMissingNodeModulesPlugin";
import TerserPlugin from "terser-webpack-plugin";
import TsconfigPathsPlugin from "tsconfig-paths-webpack-plugin";
import webpack, { Configuration, Plugin } from "webpack";
import WebpackAssetsManifest from "webpack-assets-manifest";
import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer";
// TODO: import form coral-common/version, for some reason this fails currently.
// Try again when we have a chance to upgrade typescript.
import { version } from "../common/version";
import { Config, createClientEnv } from "./config";
import paths from "./paths";
/**
* filterPlugins will filter out null values from the array of plugins, allowing
* easy embedded ternaries.
*
* @param plugins array of plugins and null values
*/
const filterPlugins = (plugins: Array<Plugin | null>): Plugin[] =>
plugins.filter(identity) as Plugin[];
// Create the build logger.
const logger = bunyan.createLogger({
name: "coral",
level: "debug",
});
interface CreateWebpackOptions {
appendPlugins?: any[];
watch?: boolean;
}
const publicPath = "/";
export default function createWebpackConfig(
config: Config,
{ appendPlugins = [], watch = false }: CreateWebpackOptions = {}
): Configuration[] {
logger.debug({ config: config.toString() }, "loaded configuration");
const maxCores = config.get("maxCores");
const env = createClientEnv(config);
const disableSourcemaps = config.get("disableSourcemaps");
const generateReport = config.get("generateReport");
const isProduction = env.NODE_ENV === "production";
const minimize = isProduction && !config.get("disableMinimize");
const treeShake = config.get("enableTreeShake");
const enableBuildCache = !isProduction;
const envStringified = {
"process.env": Object.keys(env).reduce<Record<string, string>>(
(result, key) => {
result[key] = JSON.stringify((env as any)[key]);
return result;
},
{
TALK_VERSION: JSON.stringify(version),
}
),
};
/**
* ifWatch will only include the nodes if we're in watch mode.
*/
const ifWatch = watch ? (...nodes: any[]) => nodes : () => [];
/**
* ifBuild will only include the nodes if we're in build mode.
*/
const ifBuild = !watch ? (...nodes: any[]) => nodes : () => [];
const styleLoader = {
loader: require.resolve("style-loader"),
};
const localesOptions = {
pathToLocales: paths.appLocales,
// Default locale if none was specified.
defaultLocale: config.get("defaultLocale"),
// Fallback locale if a translation was not found.
// If not set, will use the text that is already
// in the code base.
fallbackLocale: config.get("defaultLocale"),
// Common fluent files are always included in the locale bundles.
commonFiles: ["framework.ftl", "common.ftl", "ui.ftl"],
// Locales that come with the main bundle. Others are loaded on demand.
bundled: [config.get("defaultLocale")],
// All available locales can be loadable on demand.
// To restrict available locales set:
// availableLocales: [config.get("defaultLocale")],
};
const additionalPlugins = [
...ifBuild(
new MiniCssExtractPlugin({
filename: isProduction
? "assets/css/[name].[contenthash].css"
: "assets/css/[name].css",
chunkFilename: isProduction
? "assets/css/[id].[contenthash].css"
: "assets/css/[id].css",
}),
isProduction &&
new OptimizeCssnanoPlugin({
sourceMap: !disableSourcemaps,
cssnanoOptions: {
preset: [
"default",
{
discardComments: {
removeAll: true,
},
},
],
},
}),
// Pre-compress all the assets as they will be served as is.
new CompressionPlugin({})
),
...ifWatch(
// Add module names to factory functions so they appear in browser profiler.
new webpack.NamedModulesPlugin(),
// Watcher doesn't work well if you mistype casing in a path so we use
// a plugin that prints an error when you attempt to do this.
// See https://github.com/facebookincubator/create-react-app/issues/240
new CaseSensitivePathsPlugin(),
// If you require a missing module and then `npm install` it, you still have
// to restart the development server for Webpack to discover it. This plugin
// makes the discovery automatic so you don't have to restart.
// See https://github.com/facebookincubator/create-react-app/issues/186
new WatchMissingNodeModulesPlugin(paths.appNodeModules)
),
];
const devtool = disableSourcemaps
? false
: isProduction
? // We generate sourcemaps in production. This is slow but gives good results.
// You can exclude the *.map files from the build during deployment.
"source-map"
: // You may want 'eval' instead if you prefer to see the compiled output in DevTools.
// See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.
"cheap-module-source-map";
const baseConfig: Configuration = {
stats: {
// https://github.com/TypeStrong/ts-loader#transpileonly-boolean-defaultfalse
// Using transpilation only without typechecks gives warnings when we reexport types.
// We can ignore them here.
warningsFilter: /export .* was not found in/,
},
// Set webpack mode.
mode: isProduction ? "production" : "development",
optimization: {
concatenateModules: isProduction,
providedExports: true,
usedExports: true,
// We can't use side effects because it disturbs css order
// https://github.com/webpack/webpack/issues/7094.
sideEffects: false,
splitChunks: {
chunks: config.get("disableChunkSplitting") ? "async" : "all",
},
minimize: minimize || treeShake,
minimizer: [
// Minify the code.
new TerserPlugin({
terserOptions: {
compress: minimize
? {}
: {
defaults: false,
dead_code: true,
pure_getters: true,
side_effects: true,
unused: true,
},
mangle: minimize && {},
output: {
comments: !minimize,
// Turned on because emoji and regex is not minified properly using default
// https://github.com/facebookincubator/create-react-app/issues/2488
ascii_only: true,
},
safari10: true,
},
cache: enableBuildCache,
parallel: true,
sourceMap: !disableSourcemaps,
}),
],
},
devtool,
// These are the "entry points" to our application.
// This means they will be the "root" imports that are included in JS bundle.
// The first two entry points enable "hot" CSS and auto-refreshes for JS.
output: {
// Add /* filename */ comments to generated require()s in the output.
pathinfo: !isProduction,
// The dist folder.
path: paths.appDistStatic,
// Generated JS file names (with nested folders).
// There will be one main bundle, and one file per asynchronous chunk.
filename: isProduction
? "assets/js/[name].[contenthash].js"
: "assets/js/[name].js",
chunkFilename: isProduction
? "assets/js/[name].[contenthash].chunk.js"
: "assets/js/[name].chunk.js",
// We inferred the "public path" (such as / or /my-project) from homepage.
publicPath,
// Point sourcemap entries to original disk location (format as URL on Windows)
devtoolModuleFilenameTemplate: (info: any) =>
path
.relative(paths.appSrc, info.absoluteResourcePath)
.replace(/\\/g, "/"),
},
resolve: {
extensions: [".js", ".json", ".ts", ".tsx"],
plugins: [
// Support `tsconfig.json` `path` setting.
new TsconfigPathsPlugin({
configFile: paths.appTsconfig,
extensions: [".js", ".ts", ".tsx"],
}),
],
},
resolveLoader: {
// Add path to our own loaders.
modules: ["node_modules", paths.appLoaders],
},
module: {
// https://github.com/TypeStrong/ts-loader#transpileonly-boolean-defaultfalse
// Using transpilation only without typechecks gives warnings when we reexport types
// thus we can't turn on `strictExportPresence` which would turn warnings into errors.
strictExportPresence: false,
rules: [
// Disable require.ensure as it's not a standard language feature.
{ parser: { requireEnsure: false } },
{
// "oneOf" will traverse all following loaders until one will
// match the requirements. When no loader matches it will fall
// back to the "file" loader at the end of the loader list.
oneOf: [
{
test: paths.appStreamLocalesTemplate,
use: [
// This is the locales loader that loads available locales
// from a particular target.
{
loader: "locales-loader",
options: {
...localesOptions,
// Target specifies the prefix for fluent files to be loaded.
// ${target}-xyz.ftl and ${†arget}.ftl are loaded into the locales.
target: "stream",
},
},
],
},
{
test: paths.appAuthLocalesTemplate,
use: [
// This is the locales loader that loads available locales
// from a particular target.
{
loader: "locales-loader",
options: {
...localesOptions,
// Target specifies the prefix for fluent files to be loaded.
// ${target}-xyz.ftl and ${†arget}.ftl are loaded into the locales.
target: "auth",
},
},
],
},
{
test: paths.appAccountLocalesTemplate,
use: [
// This is the locales loader that loads available locales
// from a particular target.
{
loader: "locales-loader",
options: {
...localesOptions,
// Target specifies the prefix for fluent files to be loaded.
// ${target}-xyz.ftl and ${†arget}.ftl are loaded into the locales.
target: "account",
},
},
],
},
{
test: paths.appAdminLocalesTemplate,
use: [
// This is the locales loader that loads available locales
// from a particular target.
{
loader: "locales-loader",
options: {
...localesOptions,
// Target specifies the prefix for fluent files to be loaded.
// ${target}-xyz.ftl and ${†arget}.ftl are loaded into the locales.
target: "admin",
},
},
],
},
{
test: paths.appInstallLocalesTemplate,
use: [
// This is the locales loader that loads available locales
// from a particular target.
{
loader: "locales-loader",
options: {
...localesOptions,
// Target specifies the prefix for fluent files to be loaded.
// ${target}-xyz.ftl and ${†arget}.ftl are loaded into the locales.
target: "install",
},
},
],
},
// Loader for our fluent files.
{
test: /\.ftl$/,
use: ["raw-loader"],
},
// "url" loader works like "file" loader except that it embeds assets
// smaller than specified limit in bytes as data URLs to avoid requests.
// A missing `test` is equivalent to a match.
{
test: [/\.gif$/, /\.jpe?g$/, /\.png$/, /\.svg$/],
loader: require.resolve("url-loader"),
options: {
limit: 10000,
name: isProduction
? "assets/media/[name].[contenthash].[ext]"
: "assets/media/[name].[ext]",
},
},
{
test: /\.css\.ts$/,
use: [
!watch ? MiniCssExtractPlugin.loader : styleLoader,
{
loader: require.resolve("css-loader"),
options: {
modules: {
localIdentName: "[name]-[local]-[contenthash]",
},
importLoaders: 2,
sourceMap: !disableSourcemaps,
},
},
{
loader: require.resolve("postcss-loader"),
options: {
config: {
path: paths.appPostCssConfig,
},
parser: "postcss-js",
},
},
{
loader: require.resolve("babel-loader"),
options: {
configFile: false,
babelrc: false,
presets: [
"@babel/typescript",
[
"@babel/env",
{ targets: { node: "current" }, modules: "commonjs" },
],
],
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
cacheDirectory: enableBuildCache,
},
},
],
},
// Process JS with Babel.
{
test: /\.(ts|tsx)$/,
include: paths.appSrc,
use: [
{
loader: "thread-loader",
options: {
// there should be 1 cpu for the fork-ts-checker-webpack-plugin
workers: maxCores - 1,
poolTimeout: watch ? Infinity : 500, // set this to Infinity in watch mode - see https://github.com/webpack-contrib/thread-loader
},
},
{
loader: require.resolve("babel-loader"),
options: {
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
cacheDirectory: enableBuildCache,
},
},
{
loader: require.resolve("ts-loader"),
options: {
configFile: paths.appTsconfig,
compilerOptions: {
target: "es2015",
module: "esnext",
jsx: "preserve",
noEmit: false,
sourceMap: !disableSourcemaps,
},
transpileOnly: true,
// Overwrites the behavior of `include` and `exclude` to only
// include files that are actually being imported and which
// are necessary to compile the bundle.
onlyCompileBundledFiles: true,
happyPackMode: true, // IMPORTANT! use happyPackMode mode to speed-up compilation and reduce errors reported to webpack
},
},
],
},
// Makes sure node_modules are transpiled the way we need them to be.
{
test: /\.js$/,
include: /node_modules\//,
exclude: /node_modules\/(@babel|babel|core-js|regenerator-runtime)/,
use: [
{
loader: require.resolve("babel-loader"),
options: {
cacheDirectory: enableBuildCache,
},
},
],
},
// "postcss" loader applies autoprefixer to our CSS.
// "css" loader resolves paths in CSS and adds assets as dependencies.
// "style" loader turns CSS into JS modules that inject <style> tags.
// When building we use a plugin to extract that CSS to a file, and
// in watch mode "style" loader enables hot editing of CSS.
{
test: /\.css$/,
use: [
!watch ? MiniCssExtractPlugin.loader : styleLoader,
{
loader: require.resolve("css-loader"),
options: {
modules: {
localIdentName: "[name]-[local]-[contenthash]",
},
importLoaders: 1,
sourceMap: !disableSourcemaps,
},
},
{
loader: require.resolve("postcss-loader"),
options: {
config: {
path: paths.appPostCssConfig,
},
sourceMap: !disableSourcemaps,
},
},
],
},
// "file" loader makes sure those assets get served by WebpackDevServer.
// When you `import` an asset, you get its (virtual) filename.
// When building, they would get copied to the `build` folder.
// This loader doesn't use a "test" so it will catch all modules
// that fall through the other loaders.
{
// Exclude `js` files to keep "css" loader working as it injects
// its runtime that would otherwise processed through "file" loader.
// Also exclude `html` and `json` extensions so they get processed
// by webpacks internal loaders.
exclude: [/\.(js|ts|tsx)$/, /\.html$/, /\.json$/],
loader: require.resolve("file-loader"),
options: {
name: isProduction
? "assets/media/[name].[contenthash].[ext]"
: "assets/media/[name].[ext]",
},
},
],
},
// ** STOP ** Are you adding a new loader?
// Make sure to add the new loader(s) before the "file" loader.
],
},
plugins: [
// TODO: (cvle) this should work in build too but for some reasons it terminates the build afterwards.
// Preventing from running post build steps.
...ifWatch(
// We run eslint in a separate process to have a quicker build.
new ForkTsCheckerWebpackPlugin({
eslint: true,
typescript: require.resolve("typescript"),
async: true,
// TODO: (cvle) For some reason if incremental build is turned on it does not find lint errors during initial build.
useTypescriptIncrementalApi: false,
checkSyntacticErrors: true,
tsconfig: paths.appTsconfig,
})
),
// Makes some environment variables available to the JS code, for example:
// if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`.
new webpack.DefinePlugin(envStringified),
// If stats are enabled, output them!
generateReport
? new BundleAnalyzerPlugin({
analyzerMode: "static",
reportFilename: "report-assets.html",
})
: null,
...additionalPlugins,
...appendPlugins,
],
// Some libraries import Node modules but don't use them in the browser.
// Tell Webpack to provide empty mocks for them so importing them works.
node: {
dgram: "empty",
fs: "empty",
net: "empty",
tls: "empty",
child_process: "empty",
},
// Turn off performance hints during development because we don't do any
// splitting or minification in interest of speed. These warnings become
// cumbersome.
performance: {
hints: isProduction && "warning",
},
};
const devServerEntries = !watch
? []
: [
// Include an alternative client for WebpackDevServer. A client's job is to
// connect to WebpackDevServer by a socket and get notified about changes.
// When you save a file, the client will either apply hot updates (in case
// of CSS changes), or refresh the page (in case of JS changes). When you
// make a syntax error, this client will display a syntax error overlay.
// Note: instead of the default WebpackDevServer client, we use a custom one
// to bring better experience for Create React App users. You can replace
// the line below with these two lines if you prefer the stock client:
// require.resolve('webpack-dev-server/client') + '?/',
// require.resolve('webpack/hot/dev-server'),
paths.appWebpackHotDevClient,
];
return [
/* Webpack config for our different target, e.g. stream, admin... */
{
...baseConfig,
entry: {
stream: [
// We ship polyfills by default
paths.appPolyfill,
...ifBuild(paths.appPublicPath),
...devServerEntries,
paths.appStreamIndex,
],
auth: [
// We ship polyfills by default
paths.appPolyfill,
...ifBuild(paths.appPublicPath),
...devServerEntries,
paths.appAuthIndex,
// Remove deactivated entries.
],
authCallback: [
...ifBuild(paths.appPublicPath),
...devServerEntries,
paths.appAuthCallbackIndex,
],
install: [
// We ship polyfills by default
paths.appPolyfill,
...ifBuild(paths.appPublicPath),
...devServerEntries,
paths.appInstallIndex,
],
account: [
// We ship polyfills by default
paths.appPolyfill,
...ifBuild(paths.appPublicPath),
...devServerEntries,
paths.appAccountIndex,
],
admin: [
// We ship polyfills by default
paths.appPolyfill,
...ifBuild(paths.appPublicPath),
...devServerEntries,
paths.appAdminIndex,
],
},
plugins: filterPlugins([
...baseConfig.plugins!,
...ifWatch(
// This is necessary to emit hot updates
new webpack.HotModuleReplacementPlugin({
multiStep: true,
}),
// Generates an `stream.html` file with the <script> injected.
new HtmlWebpackPlugin({
filename: "stream.html",
template: paths.appStreamHTML,
chunks: ["stream"],
inject: "body",
}),
// Generates an `auth.html` file with the <script> injected.
new HtmlWebpackPlugin({
filename: "auth.html",
template: paths.appAuthHTML,
chunks: ["auth"],
inject: "body",
}),
// Generates an `auth-callback.html` file with the <script> injected.
new HtmlWebpackPlugin({
filename: "auth-callback.html",
template: paths.appAuthCallbackHTML,
chunks: ["authCallback"],
inject: "body",
}),
// Generates an `install.html` file with the <script> injected.
new HtmlWebpackPlugin({
filename: "install.html",
template: paths.appInstallHTML,
chunks: ["install"],
inject: "body",
}),
// Generates an `account.html` file with the <script> injected.
new HtmlWebpackPlugin({
filename: "account.html",
template: paths.appAccountHTML,
chunks: ["account"],
inject: "body",
}),
// Generates an `admin.html` file with the <script> injected.
new HtmlWebpackPlugin({
filename: "admin.html",
template: paths.appAdminHTML,
chunks: ["admin"],
inject: "body",
})
),
...ifBuild(
new WebpackAssetsManifest({
output: "asset-manifest.json",
entrypoints: true,
integrity: true,
})
),
]),
},
/* Webpack config for our embed */
{
...baseConfig,
optimization: {
...baseConfig.optimization,
// Ensure that we never split the embed into chunks.
splitChunks: {
chunks: "async",
},
// We can turn on sideEffects here as we don't use
// css here and don't run into: https://github.com/webpack/webpack/issues/7094
sideEffects: true,
},
entry: [
// Polyfills are in the index.ts file.
paths.appEmbedIndex,
],
output: {
...baseConfig.output,
library: "Coral",
// don't hash the embed, cache-busting must be completed by the requester
// as this lives in a static template on the embed site.
filename: "assets/js/embed.js",
},
plugins: filterPlugins([
...baseConfig.plugins!,
...ifWatch(
// Generates an `embed.html` file with the <script> injected.
new HtmlWebpackPlugin({
filename: "embed.html",
template: paths.appEmbedHTML,
inject: "head",
}),
new HtmlWebpackPlugin({
filename: "story.html",
template: paths.appEmbedStoryHTML,
inject: "head",
}),
new HtmlWebpackPlugin({
filename: "storyButton.html",
template: paths.appEmbedStoryButtonHTML,
inject: "head",
})
),
...ifBuild(
new WebpackAssetsManifest({
output: "embed-asset-manifest.json",
entrypoints: true,
integrity: true,
})
),
]),
},
/* Webpack config for count */
{
...baseConfig,
optimization: {
...baseConfig.optimization,
// Ensure that we never split the count into chunks.
splitChunks: {
chunks: "async",
},
// We can turn on sideEffects here as we don't use
// css here and don't run into: https://github.com/webpack/webpack/issues/7094
sideEffects: true,
},
entry: [paths.appCountIndex],
output: {
...baseConfig.output,
// don't hash the count, cache-busting must be completed by the requester
// as this lives in a static template on the embed site.
filename: "assets/js/count.js",
},
plugins: filterPlugins([
...baseConfig.plugins!,
...ifWatch(
// Generates an `embed.html` file with the <script> injected.
new HtmlWebpackPlugin({
filename: "count.html",
template: paths.appCountHTML,
inject: "body",
})
),
...ifBuild(
new WebpackAssetsManifest({
output: "count-asset-manifest.json",
entrypoints: true,
integrity: true,
})
),
]),
},
];
}