@xh/hoist-dev-utils 6.1.1 → 6.2.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/README.md +6 -0
- package/configureWebpack.js +172 -125
- package/package.json +30 -26
- package/static/README.md +5 -0
- package/static/requiredBlueprintIcons.js +36 -0
package/README.md
CHANGED
|
@@ -116,6 +116,12 @@ own ESLint config by specifying their `.eslintrc` file as simply:
|
|
|
116
116
|
If required, rules and other settings extended from this base configuration can be overridden at the
|
|
117
117
|
app level.
|
|
118
118
|
|
|
119
|
+
### Hoist Dev Utils Development
|
|
120
|
+
|
|
121
|
+
To develop improvements to this library, clone its repo into your workspace alongside a project
|
|
122
|
+
that uses Hoist-React, like [Toolbox](https://github.com/xh/toolbox). Then follow the instructions for
|
|
123
|
+
[yarn link](https://classic.yarnpkg.com/lang/en/docs/cli/link/) to symlink to this repo.
|
|
124
|
+
|
|
119
125
|
------------------------------------------
|
|
120
126
|
|
|
121
127
|
☎️ info@xh.io | <https://xh.io>
|
package/configureWebpack.js
CHANGED
|
@@ -28,8 +28,16 @@ const _ = require('lodash'),
|
|
|
28
28
|
// These are not direct deps of hoist-dev-utils, so might be undefined - e.g. when running
|
|
29
29
|
// this script locally to debug via `yarn link`.
|
|
30
30
|
let hoistReactPkg, reactPkg;
|
|
31
|
-
try {
|
|
32
|
-
|
|
31
|
+
try {
|
|
32
|
+
hoistReactPkg = require('@xh/hoist/package');
|
|
33
|
+
} catch (e) {
|
|
34
|
+
hoistReactPkg = {version: 'NOT_FOUND'};
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
reactPkg = require('react');
|
|
38
|
+
} catch (e) {
|
|
39
|
+
reactPkg = {version: 'NOT_FOUND'};
|
|
40
|
+
}
|
|
33
41
|
|
|
34
42
|
/**
|
|
35
43
|
* Consolidated Webpack configuration for both dev-time and production builds of Hoist React web
|
|
@@ -127,15 +135,16 @@ async function configureWebpack(env) {
|
|
|
127
135
|
analyzeBundles = env.analyzeBundles === true,
|
|
128
136
|
checkForDupePackages = env.checkForDupePackages !== false,
|
|
129
137
|
dupePackageCheckExcludes = env.dupePackageCheckExcludes || ['tslib'],
|
|
130
|
-
devHost =
|
|
131
|
-
devHttps = prodBuild
|
|
132
|
-
null
|
|
133
|
-
_.isPlainObject(env.devHttps)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
devHost = env.devHost ? env.devHost.toLowerCase() : 'localhost',
|
|
139
|
+
devHttps = prodBuild
|
|
140
|
+
? null
|
|
141
|
+
: _.isPlainObject(env.devHttps)
|
|
142
|
+
? {
|
|
143
|
+
ca: fs.readFileSync(env.devHttps.ca),
|
|
144
|
+
cert: fs.readFileSync(env.devHttps.cert),
|
|
145
|
+
key: fs.readFileSync(env.devHttps.key)
|
|
146
|
+
}
|
|
147
|
+
: !!env.devHttps,
|
|
139
148
|
devGrailsPort = env.devGrailsPort || 8080,
|
|
140
149
|
devWebpackPort = env.devWebpackPort || 3000,
|
|
141
150
|
baseUrl = env.baseUrl || (prodBuild ? '/api/' : `http://${devHost}:${devGrailsPort}/`),
|
|
@@ -187,12 +196,13 @@ async function configureWebpack(env) {
|
|
|
187
196
|
|
|
188
197
|
const srcPath = path.resolve(basePath, 'src'),
|
|
189
198
|
outPath = path.resolve(basePath, 'build'),
|
|
190
|
-
publicAssetsPath = path.resolve(basePath, 'public')
|
|
199
|
+
publicAssetsPath = path.resolve(basePath, 'public'),
|
|
200
|
+
hoistDevUtilsPath = path.resolve(basePath, 'node_modules/@xh/hoist-dev-utils');
|
|
191
201
|
|
|
192
202
|
// Resolve Hoist as either a sibling (inline, checked-out) project or a downloaded package
|
|
193
|
-
const hoistPath = inlineHoist
|
|
194
|
-
path.resolve(basePath, '../../hoist-react')
|
|
195
|
-
path.resolve(basePath, 'node_modules/@xh/hoist');
|
|
203
|
+
const hoistPath = inlineHoist
|
|
204
|
+
? path.resolve(basePath, '../../hoist-react')
|
|
205
|
+
: path.resolve(basePath, 'node_modules/@xh/hoist');
|
|
196
206
|
|
|
197
207
|
// Check for and resolve standard/expected favicons.
|
|
198
208
|
const manifestIcons = [];
|
|
@@ -203,22 +213,29 @@ async function configureWebpack(env) {
|
|
|
203
213
|
logMsg(` > ${path.basename(favicon)}`);
|
|
204
214
|
}
|
|
205
215
|
if (fs.existsSync(path.resolve(publicAssetsPath, 'favicon-192.png'))) {
|
|
206
|
-
manifestIcons.push({
|
|
216
|
+
manifestIcons.push({
|
|
217
|
+
src: '/public/favicon-192.png',
|
|
218
|
+
sizes: '192x192',
|
|
219
|
+
type: 'image/png'
|
|
220
|
+
});
|
|
207
221
|
logMsg(` > favicon-192.png`);
|
|
208
222
|
}
|
|
209
223
|
if (fs.existsSync(path.resolve(publicAssetsPath, 'favicon-512.png'))) {
|
|
210
|
-
manifestIcons.push({
|
|
224
|
+
manifestIcons.push({
|
|
225
|
+
src: '/public/favicon-512.png',
|
|
226
|
+
sizes: '512x512',
|
|
227
|
+
type: 'image/png'
|
|
228
|
+
});
|
|
211
229
|
logMsg(` > favicon-512.png`);
|
|
212
230
|
}
|
|
213
231
|
}
|
|
214
|
-
const appleTouchIconExists =
|
|
232
|
+
const appleTouchIconExists =
|
|
233
|
+
copyPublicAssets && fs.existsSync(path.resolve(publicAssetsPath, 'apple-touch-icon.png'));
|
|
215
234
|
if (appleTouchIconExists) logMsg(` > apple-touch-icon.png`);
|
|
216
235
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
bpIconStubsExist = fs.existsSync(bpIconStubsPath),
|
|
221
|
-
loadAllBlueprintJsIcons = env.loadAllBlueprintJsIcons === true || !bpIconStubsExist;
|
|
236
|
+
// Resolve path to lightweight shim for Blueprint icons bundled with this project.
|
|
237
|
+
const bpIconStubsPath = path.resolve(hoistDevUtilsPath, 'static/requiredBlueprintIcons.js'),
|
|
238
|
+
loadAllBlueprintJsIcons = env.loadAllBlueprintJsIcons === true;
|
|
222
239
|
|
|
223
240
|
// Resolve path to script for preflight checks. With HR >= v36.1 this routine has been broken
|
|
224
241
|
// out into a standalone JS file to avoid the use of inline script tags. Script will be left
|
|
@@ -242,13 +259,11 @@ async function configureWebpack(env) {
|
|
|
242
259
|
}
|
|
243
260
|
|
|
244
261
|
// When running inline, resolve inline Hoist's own node_modules package so we can tell Babel to exclude
|
|
245
|
-
const hoistNodeModulesPath = inlineHoist ?
|
|
246
|
-
path.resolve(hoistPath, 'node_modules') :
|
|
247
|
-
null;
|
|
262
|
+
const hoistNodeModulesPath = inlineHoist ? path.resolve(hoistPath, 'node_modules') : null;
|
|
248
263
|
|
|
249
264
|
// Also get a handle on the nested @xh/hoist-dev-utils/node_modules path - dev-utils dependencies
|
|
250
265
|
// (namely loaders) can be installed here due to the vagaries of node module version / conflict resolution.
|
|
251
|
-
const devUtilsNodeModulesPath = path.resolve(
|
|
266
|
+
const devUtilsNodeModulesPath = path.resolve(hoistDevUtilsPath, 'node_modules');
|
|
252
267
|
|
|
253
268
|
// Determine source map (devtool) mode.
|
|
254
269
|
let devtool;
|
|
@@ -263,7 +278,10 @@ async function configureWebpack(env) {
|
|
|
263
278
|
}
|
|
264
279
|
|
|
265
280
|
// Ignore DefinePlugin warnings on mis-matched process.env when reactProdMode enabled during local development.
|
|
266
|
-
const ignoreWarnings =
|
|
281
|
+
const ignoreWarnings =
|
|
282
|
+
prodBuild !== reactProdMode
|
|
283
|
+
? [{message: /Conflicting values for 'process.env.NODE_ENV'/}]
|
|
284
|
+
: [];
|
|
267
285
|
|
|
268
286
|
// Parse CHANGELOG.md and write to tmp .json file, if requested. Write fallback file if disabled
|
|
269
287
|
// or parsing fails, then install a resolver alias to support import from XH.changelogService.
|
|
@@ -316,10 +334,7 @@ async function configureWebpack(env) {
|
|
|
316
334
|
apps.forEach(app => {
|
|
317
335
|
// Ensure core-js and regenerator-runtime both imported for every app bundle - they are
|
|
318
336
|
// specified as dependencies by Hoist and imported once in its polyfills.js file.
|
|
319
|
-
appEntryPoints[app.name] = [
|
|
320
|
-
path.resolve(hoistPath, 'static/polyfills.js'),
|
|
321
|
-
app.path
|
|
322
|
-
];
|
|
337
|
+
appEntryPoints[app.name] = [path.resolve(hoistPath, 'static/polyfills.js'), app.path];
|
|
323
338
|
});
|
|
324
339
|
|
|
325
340
|
logSep();
|
|
@@ -340,7 +355,9 @@ async function configureWebpack(env) {
|
|
|
340
355
|
output: {
|
|
341
356
|
// Output built assets in directories per entry point / chunk.
|
|
342
357
|
// Use chunkhash in prod to get distinct hashes for app vs. common chunks (throws error in dev - investigate)
|
|
343
|
-
filename: prodBuild
|
|
358
|
+
filename: prodBuild
|
|
359
|
+
? '[name]/[name].[chunkhash:8].js'
|
|
360
|
+
: '[name]/[name].[fullhash:8].js',
|
|
344
361
|
path: outPath,
|
|
345
362
|
// (URL) path on which fully built app is served - i.e. root context
|
|
346
363
|
publicPath: contextRoot,
|
|
@@ -361,7 +378,11 @@ async function configureWebpack(env) {
|
|
|
361
378
|
// e.g. `app.js`, `admin.js`, and `admin~app.js` for code shared by both apps.
|
|
362
379
|
splitChunks: {
|
|
363
380
|
chunks: 'all',
|
|
364
|
-
name: (module, chunks) =>
|
|
381
|
+
name: (module, chunks) =>
|
|
382
|
+
chunks
|
|
383
|
+
.sort()
|
|
384
|
+
.map(it => it.name)
|
|
385
|
+
.join('~')
|
|
365
386
|
},
|
|
366
387
|
|
|
367
388
|
// Improved debugging with readable module/chunk names.
|
|
@@ -397,7 +418,6 @@ async function configureWebpack(env) {
|
|
|
397
418
|
rules: [
|
|
398
419
|
{
|
|
399
420
|
oneOf: [
|
|
400
|
-
|
|
401
421
|
//------------------------
|
|
402
422
|
// Type mapping for .mjs files, used by the stylis library distribution.
|
|
403
423
|
// We have a transitive dep on stylis via: react-select > emotion > stylis
|
|
@@ -451,6 +471,16 @@ async function configureWebpack(env) {
|
|
|
451
471
|
// not required. See https://babeljs.io/docs/en/babel-preset-env#bugfixes.
|
|
452
472
|
bugfixes: true,
|
|
453
473
|
|
|
474
|
+
// Ensure expected transform plugins are enabled for latest features.
|
|
475
|
+
// (Note these plugins are all generally bundled with preset-env.)
|
|
476
|
+
include: [
|
|
477
|
+
'transform-class-properties',
|
|
478
|
+
'transform-nullish-coalescing-operator',
|
|
479
|
+
'transform-optional-chaining',
|
|
480
|
+
'transform-private-methods',
|
|
481
|
+
'transform-private-property-in-object'
|
|
482
|
+
],
|
|
483
|
+
|
|
454
484
|
// Allow direct overrides from env config.
|
|
455
485
|
...babelPresetEnvOptions
|
|
456
486
|
}
|
|
@@ -460,47 +490,48 @@ async function configureWebpack(env) {
|
|
|
460
490
|
// Support Typescript via Babel. `isTSX` option allows use of JSX inline with
|
|
461
491
|
// .js files for older JS apps. Typescript apps must use the .tsx extension for
|
|
462
492
|
// any files containing JSX syntax.
|
|
463
|
-
[
|
|
493
|
+
[
|
|
494
|
+
'@babel/plugin-transform-typescript',
|
|
495
|
+
{allowDeclareFields: true, isTSX: true}
|
|
496
|
+
],
|
|
464
497
|
|
|
465
498
|
// Support our current decorator syntax, for MobX and Hoist decorators.
|
|
466
499
|
// See notes @ https://babeljs.io/docs/en/babel-plugin-proposal-decorators#legacy
|
|
467
500
|
// and https://mobx.js.org/enabling-decorators.html#babel-7
|
|
468
501
|
['@babel/plugin-proposal-decorators', {version: 'legacy'}],
|
|
469
502
|
|
|
470
|
-
// Support class-level fields.
|
|
471
|
-
// Must come after decorators plugin as per Babel docs linked above.
|
|
472
|
-
['@babel/plugin-proposal-class-properties'],
|
|
473
|
-
|
|
474
|
-
// Support private methods + properties.
|
|
475
|
-
['@babel/plugin-proposal-private-methods'],
|
|
476
|
-
['@babel/plugin-proposal-private-property-in-object'],
|
|
477
|
-
|
|
478
|
-
// Support `let x = foo?.bar`.
|
|
479
|
-
['@babel/plugin-proposal-optional-chaining'],
|
|
480
|
-
|
|
481
|
-
// Support `let x = foo.bar ?? 'default'`.
|
|
482
|
-
['@babel/plugin-proposal-nullish-coalescing-operator'],
|
|
483
|
-
|
|
484
503
|
// Avoid importing every FA icon ever made.
|
|
485
504
|
// See https://github.com/FortAwesome/react-fontawesome/issues/70
|
|
486
|
-
[
|
|
487
|
-
'
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
505
|
+
[
|
|
506
|
+
require('babel-plugin-transform-imports'),
|
|
507
|
+
{
|
|
508
|
+
'@fortawesome/pro-light-svg-icons': {
|
|
509
|
+
transform:
|
|
510
|
+
'@fortawesome/pro-light-svg-icons/${member}',
|
|
511
|
+
skipDefaultConversion: true
|
|
512
|
+
},
|
|
513
|
+
'@fortawesome/pro-regular-svg-icons': {
|
|
514
|
+
transform:
|
|
515
|
+
'@fortawesome/pro-regular-svg-icons/${member}',
|
|
516
|
+
skipDefaultConversion: true
|
|
517
|
+
},
|
|
518
|
+
'@fortawesome/pro-solid-svg-icons': {
|
|
519
|
+
transform:
|
|
520
|
+
'@fortawesome/pro-solid-svg-icons/${member}',
|
|
521
|
+
skipDefaultConversion: true
|
|
522
|
+
},
|
|
523
|
+
'@fortawesome/pro-thin-svg-icons': {
|
|
524
|
+
transform:
|
|
525
|
+
'@fortawesome/pro-thin-svg-icons/${member}',
|
|
526
|
+
skipDefaultConversion: true
|
|
527
|
+
},
|
|
528
|
+
'@fortawesome/free-brands-svg-icons': {
|
|
529
|
+
transform:
|
|
530
|
+
'@fortawesome/free-brands-svg-icons/${member}',
|
|
531
|
+
skipDefaultConversion: true
|
|
532
|
+
}
|
|
502
533
|
}
|
|
503
|
-
|
|
534
|
+
]
|
|
504
535
|
],
|
|
505
536
|
// Cache for dev builds, don't bother compressing.
|
|
506
537
|
cacheDirectory: !prodBuild,
|
|
@@ -513,7 +544,9 @@ async function configureWebpack(env) {
|
|
|
513
544
|
include: [srcPath, hoistPath, ...babelIncludePaths],
|
|
514
545
|
// In inline mode also *avoid* transpiling inline hoist's own
|
|
515
546
|
// node_modules libraries.
|
|
516
|
-
exclude: inlineHoist
|
|
547
|
+
exclude: inlineHoist
|
|
548
|
+
? [hoistNodeModulesPath, ...babelExcludePaths]
|
|
549
|
+
: babelExcludePaths
|
|
517
550
|
},
|
|
518
551
|
|
|
519
552
|
//------------------------
|
|
@@ -545,13 +578,16 @@ async function configureWebpack(env) {
|
|
|
545
578
|
options: {
|
|
546
579
|
postcssOptions: {
|
|
547
580
|
plugins: [
|
|
548
|
-
require('postcss-flexbugs-fixes'),
|
|
549
|
-
[
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
581
|
+
require('postcss-flexbugs-fixes'), // Inclusion of postcss-flexbugs-fixes is from CRA.
|
|
582
|
+
[
|
|
583
|
+
'autoprefixer',
|
|
584
|
+
{
|
|
585
|
+
// We still want to provide an array of target browsers
|
|
586
|
+
// that can be passed to / managed centrally by this script.
|
|
587
|
+
overrideBrowserslist: targetBrowsers,
|
|
588
|
+
flexbox: 'no-2009'
|
|
589
|
+
}
|
|
590
|
+
]
|
|
555
591
|
]
|
|
556
592
|
}
|
|
557
593
|
}
|
|
@@ -562,7 +598,6 @@ async function configureWebpack(env) {
|
|
|
562
598
|
]
|
|
563
599
|
},
|
|
564
600
|
|
|
565
|
-
|
|
566
601
|
//------------------------
|
|
567
602
|
// Fall-through entry to process all other assets via a file-loader.
|
|
568
603
|
// (Exclude config here is from CRA source config - commented there, but didn't understand).
|
|
@@ -584,10 +619,12 @@ async function configureWebpack(env) {
|
|
|
584
619
|
new CleanWebpackPlugin(),
|
|
585
620
|
|
|
586
621
|
// Load only the BlueprintJS icons used by Hoist-React components.
|
|
587
|
-
!loadAllBlueprintJsIcons
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
622
|
+
!loadAllBlueprintJsIcons
|
|
623
|
+
? new webpack.NormalModuleReplacementPlugin(
|
|
624
|
+
/.*\/@blueprintjs\/icons\/lib\/esm\/iconSvgPaths.*/,
|
|
625
|
+
bpIconStubsPath
|
|
626
|
+
)
|
|
627
|
+
: undefined,
|
|
591
628
|
|
|
592
629
|
// Inject global constants at compile time.
|
|
593
630
|
new webpack.DefinePlugin({
|
|
@@ -614,9 +651,9 @@ async function configureWebpack(env) {
|
|
|
614
651
|
patterns: _.compact([
|
|
615
652
|
{from: preflightScriptPath, to: 'public'},
|
|
616
653
|
{from: preloadSpinnerPath, to: 'public'},
|
|
617
|
-
copyPublicAssets
|
|
618
|
-
{from: path.resolve(basePath, 'public'), to: 'public'}
|
|
619
|
-
undefined
|
|
654
|
+
copyPublicAssets
|
|
655
|
+
? {from: path.resolve(basePath, 'public'), to: 'public'}
|
|
656
|
+
: undefined
|
|
620
657
|
])
|
|
621
658
|
}),
|
|
622
659
|
|
|
@@ -662,17 +699,21 @@ async function configureWebpack(env) {
|
|
|
662
699
|
}),
|
|
663
700
|
|
|
664
701
|
// Support an optional post-build/run interactive treemap of output bundles and their sizes / contents.
|
|
665
|
-
analyzeBundles
|
|
666
|
-
|
|
667
|
-
|
|
702
|
+
analyzeBundles
|
|
703
|
+
? new BundleAnalyzerPlugin({
|
|
704
|
+
analyzerMode: 'server'
|
|
705
|
+
})
|
|
706
|
+
: undefined,
|
|
668
707
|
|
|
669
708
|
// Warn on dupe package included in bundle due to multiple, conflicting versions.
|
|
670
|
-
checkForDupePackages
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
709
|
+
checkForDupePackages
|
|
710
|
+
? new DuplicatePackageCheckerPlugin({
|
|
711
|
+
verbose: true,
|
|
712
|
+
showHelp: false,
|
|
713
|
+
strict: false,
|
|
714
|
+
exclude: instance => dupePackageCheckExcludes.includes(instance.name)
|
|
715
|
+
})
|
|
716
|
+
: undefined,
|
|
676
717
|
|
|
677
718
|
// Display build progress - enable profile for per-loader/file type stats.
|
|
678
719
|
new WebpackBar({
|
|
@@ -682,7 +723,6 @@ async function configureWebpack(env) {
|
|
|
682
723
|
|
|
683
724
|
// Environment-specific plugins.
|
|
684
725
|
...(prodBuild ? extraPluginsProd(terserOptions) : extraPluginsDev())
|
|
685
|
-
|
|
686
726
|
].filter(Boolean),
|
|
687
727
|
|
|
688
728
|
devtool: devtool,
|
|
@@ -690,23 +730,25 @@ async function configureWebpack(env) {
|
|
|
690
730
|
ignoreWarnings: ignoreWarnings,
|
|
691
731
|
|
|
692
732
|
// Inline dev-time configuration for webpack-dev-server.
|
|
693
|
-
devServer: prodBuild
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
733
|
+
devServer: prodBuild
|
|
734
|
+
? undefined
|
|
735
|
+
: {
|
|
736
|
+
https: devHttps,
|
|
737
|
+
host: devHost,
|
|
738
|
+
port: devWebpackPort,
|
|
739
|
+
hot: true,
|
|
740
|
+
client: {overlay: true},
|
|
741
|
+
open: env.devServerOpenPage ? [env.devServerOpenPage] : false,
|
|
742
|
+
// Support HTML5 history routes for apps, with /appName/ as the base route for each
|
|
743
|
+
historyApiFallback: {
|
|
744
|
+
rewrites: appNames.map(appName => {
|
|
745
|
+
return {
|
|
746
|
+
from: new RegExp(`^/${appName}`),
|
|
747
|
+
to: `/${appName}/index.html`
|
|
748
|
+
};
|
|
749
|
+
})
|
|
750
|
+
}
|
|
751
|
+
}
|
|
710
752
|
};
|
|
711
753
|
}
|
|
712
754
|
|
|
@@ -714,7 +756,6 @@ async function configureWebpack(env) {
|
|
|
714
756
|
// Implementation
|
|
715
757
|
//------------------------
|
|
716
758
|
class HoistManifestPlugin {
|
|
717
|
-
|
|
718
759
|
constructor(content = {}) {
|
|
719
760
|
this.content = content;
|
|
720
761
|
}
|
|
@@ -725,22 +766,24 @@ class HoistManifestPlugin {
|
|
|
725
766
|
{RawSource} = compiler.webpack.sources;
|
|
726
767
|
|
|
727
768
|
// Tap into compilation hook which gives compilation as argument to the callback function
|
|
728
|
-
compiler.hooks.compilation.tap(pluginName,
|
|
729
|
-
compilation.hooks.processAssets.tap(
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
769
|
+
compiler.hooks.compilation.tap(pluginName, compilation => {
|
|
770
|
+
compilation.hooks.processAssets.tap(
|
|
771
|
+
{
|
|
772
|
+
name: pluginName,
|
|
773
|
+
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
774
|
+
},
|
|
775
|
+
() => {
|
|
776
|
+
compilation.emitAsset(
|
|
777
|
+
'/public/manifest.json',
|
|
778
|
+
new RawSource(JSON.stringify(this.content))
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
);
|
|
738
782
|
});
|
|
739
783
|
}
|
|
740
784
|
}
|
|
741
785
|
|
|
742
|
-
|
|
743
|
-
const extraPluginsProd = (terserOptions) => {
|
|
786
|
+
const extraPluginsProd = terserOptions => {
|
|
744
787
|
return [
|
|
745
788
|
// Extract built CSS files into subdirectories by chunk / entry point name.
|
|
746
789
|
new MiniCssExtractPlugin({
|
|
@@ -793,7 +836,11 @@ function getChunkCombinations(appNames) {
|
|
|
793
836
|
return ret;
|
|
794
837
|
}
|
|
795
838
|
|
|
796
|
-
function logSep() {
|
|
797
|
-
|
|
839
|
+
function logSep() {
|
|
840
|
+
console.log(':------------------------------------');
|
|
841
|
+
}
|
|
842
|
+
function logMsg(msg) {
|
|
843
|
+
console.log(`: ${msg}`);
|
|
844
|
+
}
|
|
798
845
|
|
|
799
846
|
module.exports = configureWebpack;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist-dev-utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Utilities for configuring builds of Hoist-React client applications.",
|
|
5
5
|
"repository": "github:xh/hoist-dev-utils",
|
|
6
6
|
"homepage": "https://github.com/xh/hoist-dev-utils",
|
|
@@ -8,45 +8,49 @@
|
|
|
8
8
|
"author": "Extremely Heavy Industries, Inc.",
|
|
9
9
|
"license": "Apache-2.0",
|
|
10
10
|
"files": [
|
|
11
|
-
"configureWebpack.js"
|
|
11
|
+
"configureWebpack.js",
|
|
12
|
+
"static/**/*"
|
|
12
13
|
],
|
|
13
14
|
"dependencies": {
|
|
14
|
-
"@babel/core": "^7.
|
|
15
|
-
"@babel/plugin-proposal-decorators": "^7.
|
|
16
|
-
"@babel/preset-env": "^7.
|
|
17
|
-
"@babel/preset-react": "^7.
|
|
18
|
-
"@babel/preset-typescript": "^7.
|
|
15
|
+
"@babel/core": "^7.22.1",
|
|
16
|
+
"@babel/plugin-proposal-decorators": "^7.22.3",
|
|
17
|
+
"@babel/preset-env": "^7.22.4",
|
|
18
|
+
"@babel/preset-react": "^7.22.3",
|
|
19
|
+
"@babel/preset-typescript": "^7.21.5",
|
|
19
20
|
"@cerner/duplicate-package-checker-webpack-plugin": "~2.3.0",
|
|
20
|
-
"@types/lodash": "
|
|
21
|
-
"@types/react": "
|
|
22
|
-
"@xh/eslint-config": "^5.0
|
|
23
|
-
"autoprefixer": "~10.4.
|
|
24
|
-
"babel-loader": "~9.1.
|
|
21
|
+
"@types/lodash": "4.x",
|
|
22
|
+
"@types/react": "18.x",
|
|
23
|
+
"@xh/eslint-config": "^5.0",
|
|
24
|
+
"autoprefixer": "~10.4.14",
|
|
25
|
+
"babel-loader": "~9.1.2",
|
|
25
26
|
"babel-plugin-transform-imports": "~2.0.0",
|
|
26
27
|
"case-sensitive-paths-webpack-plugin": "~2.4.0",
|
|
27
|
-
"changelog-parser": "~
|
|
28
|
+
"changelog-parser": "~3.0.1",
|
|
28
29
|
"clean-webpack-plugin": "~4.0.0",
|
|
29
30
|
"copy-webpack-plugin": "~11.0.0",
|
|
30
|
-
"css-loader": "~6.
|
|
31
|
+
"css-loader": "~6.8.1",
|
|
31
32
|
"file-loader": "~6.2.0",
|
|
32
33
|
"html-webpack-plugin": "~5.5.0",
|
|
33
34
|
"html-webpack-tags-plugin": "~3.0.2",
|
|
34
35
|
"lodash": "~4.17.21",
|
|
35
|
-
"mini-css-extract-plugin": "~2.7.
|
|
36
|
-
"postcss": "~8.4.
|
|
36
|
+
"mini-css-extract-plugin": "~2.7.5",
|
|
37
|
+
"postcss": "~8.4.21",
|
|
37
38
|
"postcss-flexbugs-fixes": "~5.0.2",
|
|
38
|
-
"postcss-loader": "~7.0
|
|
39
|
-
"rimraf": "~
|
|
40
|
-
"sass": "~1.
|
|
41
|
-
"sass-loader": "~13.
|
|
39
|
+
"postcss-loader": "~7.3.0",
|
|
40
|
+
"rimraf": "~4.4.0",
|
|
41
|
+
"sass": "~1.62.1",
|
|
42
|
+
"sass-loader": "~13.3.0",
|
|
42
43
|
"sass-material-colors": "~0.0.5",
|
|
43
|
-
"style-loader": "~3.3.
|
|
44
|
-
"terser-webpack-plugin": "~5.3.
|
|
44
|
+
"style-loader": "~3.3.2",
|
|
45
|
+
"terser-webpack-plugin": "~5.3.7",
|
|
45
46
|
"url-loader": "~4.1.1",
|
|
46
|
-
"webpack": "~5.
|
|
47
|
-
"webpack-bundle-analyzer": "~4.
|
|
48
|
-
"webpack-cli": "~5.
|
|
49
|
-
"webpack-dev-server": "~4.
|
|
47
|
+
"webpack": "~5.84.1",
|
|
48
|
+
"webpack-bundle-analyzer": "~4.8.0",
|
|
49
|
+
"webpack-cli": "~5.1.1",
|
|
50
|
+
"webpack-dev-server": "~4.15.0",
|
|
50
51
|
"webpackbar": "~5.0.2"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"prettier": "^2.8.8"
|
|
51
55
|
}
|
|
52
56
|
}
|
package/static/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Build-related files
|
|
2
|
+
|
|
3
|
+
* `requiredBlueprintIcons.js` - included by hoist-dev-utils >= v6.2 as a (very) streamlined replacement for the
|
|
4
|
+
full set of Blueprint JS icons otherwise required by that library. See the comment at the top of the file for
|
|
5
|
+
additional details and links.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file replaces the MUCH larger versions included within the blueprintjs/icons dependency,
|
|
3
|
+
* which itself is required by Blueprint core. This file is swapped in at build-time by the
|
|
4
|
+
* `@xh/hoist-dev-utils` webpack config to only bundle the icons required by BP-based Hoist React
|
|
5
|
+
* components, nicely reducing overall app bundle size.
|
|
6
|
+
*
|
|
7
|
+
* For further details, see https://github.com/xh/hoist-react/issues/1963,
|
|
8
|
+
* and https://github.com/xh/hoist-dev-utils/issues/44.
|
|
9
|
+
* See the dev-utils `configureWebpack()` method for the implementation referencing this file.
|
|
10
|
+
*/
|
|
11
|
+
export const IconSvgPaths16 = {
|
|
12
|
+
// used on context menu menuItem when a menu has submenus
|
|
13
|
+
'caret-right': ['M11 8c0-.15-.07-.28-.17-.37l-4-3.5A.495.495 0 006 4.5v7a.495.495 0 00.83.37l4-3.5c.1-.09.17-.22.17-.37z'],
|
|
14
|
+
// used in datepicker's calendar scroll
|
|
15
|
+
'chevron-left': ['M7.41 8l3.29-3.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-4 4C5.11 7.47 5 7.72 5 8c0 .28.11.53.29.71l4 4a1.003 1.003 0 001.42-1.42L7.41 8z'],
|
|
16
|
+
'chevron-right': ['M10.71 7.29l-4-4a1.003 1.003 0 00-1.42 1.42L8.59 8 5.3 11.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4-4c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z'],
|
|
17
|
+
// used on toast close buttons
|
|
18
|
+
'cross': ['M9.41 8l3.29-3.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L8 6.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42L6.59 8 3.3 11.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L8 9.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L9.41 8z'],
|
|
19
|
+
// used on datepicker's month picker
|
|
20
|
+
'double-caret-vertical': ['M5 7h6a1.003 1.003 0 00.71-1.71l-3-3C8.53 2.11 8.28 2 8 2s-.53.11-.71.29l-3 3A1.003 1.003 0 005 7zm6 2H5a1.003 1.003 0 00-.71 1.71l3 3c.18.18.43.29.71.29s.53-.11.71-.29l3-3A1.003 1.003 0 0011 9z'],
|
|
21
|
+
// used on dialog close buttons
|
|
22
|
+
'small-cross': ['M9.41 8l2.29-2.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L8 6.59l-2.29-2.3a1.003 1.003 0 00-1.42 1.42L6.59 8 4.3 10.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L8 9.41l2.29 2.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L9.41 8z']
|
|
23
|
+
|
|
24
|
+
};
|
|
25
|
+
export const IconSvgPaths20 = {
|
|
26
|
+
'caret-right': ['M14 10c0-.31-.15-.57-.37-.76l.01-.01-6-5-.01.01C7.46 4.1 7.24 4 7 4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1 .24 0 .46-.1.63-.24l.01.01 6-5-.01-.01c.22-.19.37-.45.37-.76z'],
|
|
27
|
+
'chevron-left': ['M8.41 10l5.29-5.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71l-6 6c-.18.18-.29.43-.29.71 0 .28.11.53.29.71l6 6a1.003 1.003 0 001.42-1.42L8.41 10z'],
|
|
28
|
+
'chevron-right': ['M13.71 9.29l-6-6a1.003 1.003 0 00-1.42 1.42l5.3 5.29-5.29 5.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l6-6c.18-.18.29-.43.29-.71 0-.28-.11-.53-.29-.71z'],
|
|
29
|
+
'cross': ['M11.41 10l4.29-4.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L10 8.59l-4.29-4.3a1.003 1.003 0 00-1.42 1.42L8.59 10 4.3 14.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l4.29-4.3 4.29 4.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L11.41 10z'],
|
|
30
|
+
'double-caret-vertical': ['M5 9h10c.55 0 1-.45 1-1 0-.24-.1-.46-.24-.63l.01-.01-5-6-.01.01C10.57 1.15 10.31 1 10 1s-.57.15-.76.37l-.01-.01-5 6 .01.01C4.1 7.54 4 7.76 4 8c0 .55.45 1 1 1zm10 2H5c-.55 0-1 .45-1 1 0 .24.1.46.24.63l-.01.01 5 6 .01-.01c.19.22.45.37.76.37s.57-.15.76-.37l.01.01 5-6-.01-.01c.14-.17.24-.39.24-.63 0-.55-.45-1-1-1z'],
|
|
31
|
+
'small-cross': ['M11.41 10l3.29-3.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L10 8.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42L8.59 10 5.3 13.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71l3.29-3.3 3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L11.41 10z']
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export function iconNameToPathsRecordKey(name) {
|
|
35
|
+
return name
|
|
36
|
+
}
|