@xh/hoist-dev-utils 11.0.0 → 11.0.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/README.md +51 -31
- package/configureWebpack.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,25 +5,29 @@ repository is made available as the `@xh/hoist-dev-utils`
|
|
|
5
5
|
[package on npm](https://www.npmjs.com/package/@xh/hoist-dev-utils) for import and use by
|
|
6
6
|
applications.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
## Shared development dependencies
|
|
9
9
|
|
|
10
10
|
The package.json file in this repository specifies a set of development dependencies required for
|
|
11
11
|
building Hoist React applications. Those applications can specify `@xh/hoist-dev-utils` as a dev
|
|
12
12
|
dependency and transitively bring in libs for Webpack and all associated plugins used in app builds,
|
|
13
13
|
including Webpack Dev Server, Babel, and other essential loaders.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
apps might wish to configure additional tooling such as stylelint (for linting SASS files) or
|
|
17
|
-
lint-staged and husky (for running linters as a pre-commit git hook). See the
|
|
18
|
-
[Toolbox package.json](https://github.com/xh/toolbox/blob/develop/client-app/package.json) for
|
|
19
|
-
examples of these libraries in action.
|
|
15
|
+
While Hoist Dev Utils provides most essential dev dependencies for Hoist React, apps typically also include:
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
* `husky` + `lint-staged` for pre-commit linting and other actions, such as running `tsc`.
|
|
18
|
+
* `prettier` + `eslint-config-prettier` for opinionated code formatting.
|
|
19
|
+
* `stylelint` + `stylelint-config-standard-scss` for SASS/SCSS linting.
|
|
20
|
+
* `typescript` + relevant `@types` definitions, specifically `@types/react` + `@types/react-dom`.
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
See the [Toolbox package.json](https://github.com/xh/toolbox/blob/develop/client-app/package.json) for examples of these
|
|
23
|
+
libraries in action.
|
|
24
|
+
|
|
25
|
+
## Webpack configuration
|
|
26
|
+
|
|
27
|
+
The `configureWebpack.js` module exports a single `configureWebpack()` method that can be used to
|
|
24
28
|
output a complete Webpack configuration. This includes support for transpiling and bundling multiple
|
|
25
29
|
client application entry points with preconfigured loaders for JS code (Babel), styles
|
|
26
|
-
(CSS/SASS/PostCSS) and HTML index file generation. See the docs within
|
|
30
|
+
(CSS/SASS/PostCSS) and HTML index file generation. See the docs within `configureWebpack.js` for supported
|
|
27
31
|
arguments and additional details.
|
|
28
32
|
|
|
29
33
|
The generated Webpack configuration also sets the value of several XH globals within the built JS
|
|
@@ -33,14 +37,14 @@ code, via the Webpack DefinePlugin. These include `XH.appCode` and `XH.appName`
|
|
|
33
37
|
The intention is to reduce application webpack config files to a minimal and manageable subset of
|
|
34
38
|
options. An example of such a file would be:
|
|
35
39
|
|
|
36
|
-
```
|
|
40
|
+
```typescript
|
|
37
41
|
const configureWebpack = require('@xh/hoist-dev-utils/configureWebpack');
|
|
38
42
|
|
|
39
43
|
module.exports = (env = {}) => {
|
|
40
44
|
return configureWebpack({
|
|
41
45
|
appCode: 'myApp',
|
|
42
46
|
appName: 'My Application',
|
|
43
|
-
appVersion:
|
|
47
|
+
appVersion: '1.0-SNAPSHOT',
|
|
44
48
|
favicon: './public/favicon.svg',
|
|
45
49
|
devServerOpenPage: 'app/',
|
|
46
50
|
...env
|
|
@@ -56,12 +60,12 @@ versioned 1.2.3 release).
|
|
|
56
60
|
See the [Hoist React docs](https://github.com/xh/hoist-react/blob/develop/docs/build-and-deploy.md)
|
|
57
61
|
for step-by-step details on the build process.
|
|
58
62
|
|
|
59
|
-
|
|
63
|
+
## Favicons
|
|
60
64
|
|
|
61
65
|
To include a favicon with your app, provide the `favicon` option to `configureWebpack()`. This can be either
|
|
62
66
|
a `png` or an `svg` file:
|
|
63
67
|
|
|
64
|
-
```
|
|
68
|
+
```typescript
|
|
65
69
|
return configureWebpack({
|
|
66
70
|
...,
|
|
67
71
|
favicon: './public/favicon.svg',
|
|
@@ -70,60 +74,76 @@ return configureWebpack({
|
|
|
70
74
|
```
|
|
71
75
|
|
|
72
76
|
If your app is intended to be used on mobile devices, you may want to also include a wider variety of favicons.
|
|
73
|
-
The following files will be automatically bundled in your app's manifest.json if they are found in your project's
|
|
77
|
+
The following files will be automatically bundled in your app's `manifest.json` if they are found in your project's
|
|
74
78
|
`/client-app/public` folder:
|
|
75
79
|
|
|
76
80
|
+ `favicon-192.png` (192px x 192px)
|
|
77
81
|
+ `favicon-512.png` (512px x 512px)
|
|
78
82
|
+ `apple-touch-icon.png` (180px x 180px)
|
|
79
83
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
### Generating favicons via `svg-favicon.sh`
|
|
85
|
+
|
|
86
|
+
You can use the `svg-favicon.sh` script included in this repo to automatically create these favicons from a square SVG.
|
|
87
|
+
Note that this script requires inkscape to be installed. Download the latest version
|
|
88
|
+
from [https://inkscape.org/](https://inkscape.org/) or install on Mac via Homebrew with `brew install inkscape`.
|
|
83
89
|
|
|
84
90
|
Inkscape includes a command-line interface which is leveraged by the script. In order for the script to be able to use
|
|
85
91
|
it, you must first symlink Inkscape to `/usr/local/bin`. (Note this step is _not_ required if you have installed via
|
|
86
92
|
Homebrew.)
|
|
87
93
|
|
|
88
94
|
```shell
|
|
95
|
+
# Not required if installed via Homebrew!
|
|
89
96
|
ln -s /Applications/Inkscape.app/Contents/MacOS/inkscape \
|
|
90
97
|
/usr/local/bin/inkscape
|
|
91
98
|
```
|
|
92
99
|
|
|
93
|
-
Then run the script, passing a path to the SVG file as the argument. The command below assumes that you have
|
|
94
|
-
`hoist-dev-utils` checked out as a sibling of your top-level project directory, and that you are running the command
|
|
95
|
-
from within `$projectDir/client-app/public`:
|
|
100
|
+
Then run the script, passing a path to the SVG file as the argument. The command below assumes that you have
|
|
101
|
+
`hoist-dev-utils` checked out as a sibling of your top-level project directory, and that you are running the command
|
|
102
|
+
from within `$projectDir/client-app/public`:
|
|
96
103
|
|
|
97
104
|
```shell
|
|
98
105
|
../../../hoist-dev-utils/svg-favicon.sh favicon.svg
|
|
99
106
|
```
|
|
100
107
|
|
|
101
|
-
|
|
108
|
+
## ESLint Configuration
|
|
102
109
|
|
|
103
110
|
✨ This package includes a development dependency on the `@xh/eslint-config` package.
|
|
104
111
|
[That package](https://github.com/xh/eslint-config) exports an eslint configuration object with
|
|
105
|
-
|
|
112
|
+
XH's recommended coding conventions and best practices for Hoist React based development.
|
|
106
113
|
|
|
107
114
|
Applications that already have `@xh/hoist-dev-utils` as a dependency can use these rules for their
|
|
108
|
-
own ESLint config
|
|
115
|
+
own ESLint config with an `eslint.config.js` file similar to:
|
|
109
116
|
|
|
117
|
+
```javascript
|
|
118
|
+
const {defineConfig, globalIgnores} = require('eslint/config'),
|
|
119
|
+
xhEslintConfig = require('@xh/eslint-config'),
|
|
120
|
+
prettier = require('eslint-config-prettier');
|
|
121
|
+
|
|
122
|
+
module.exports = defineConfig([
|
|
123
|
+
{
|
|
124
|
+
extends: [xhEslintConfig, prettier]
|
|
125
|
+
},
|
|
126
|
+
globalIgnores(['build/**/*', '.yarn/**/*', 'node_modules/**/*'])
|
|
127
|
+
]);
|
|
110
128
|
```
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
129
|
+
|
|
130
|
+
This example file:
|
|
131
|
+
|
|
132
|
+
* Requires and specifies XH's recommended presets.
|
|
133
|
+
* Overlays with Prettier-specific linter rules (assuming the project is using Prettier)
|
|
134
|
+
* Ignores build outputs, bundled `.yarn` (if included in your project) and `node_modules`.
|
|
115
135
|
|
|
116
136
|
If required, rules and other settings extended from this base configuration can be overridden at the
|
|
117
137
|
app level.
|
|
118
138
|
|
|
119
|
-
|
|
139
|
+
## Hoist Dev Utils Development
|
|
120
140
|
|
|
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).
|
|
141
|
+
To develop improvements to this library, clone its repo into your workspace alongside a project
|
|
142
|
+
that uses Hoist-React, like [Toolbox](https://github.com/xh/toolbox). Then follow the instructions for
|
|
123
143
|
[yarn link](https://classic.yarnpkg.com/lang/en/docs/cli/link/) to symlink to this repo.
|
|
124
144
|
|
|
125
145
|
------------------------------------------
|
|
126
146
|
|
|
127
147
|
☎️ info@xh.io | <https://xh.io>
|
|
128
148
|
|
|
129
|
-
Copyright ©
|
|
149
|
+
Copyright © 2025 Extremely Heavy Industries Inc.
|
package/configureWebpack.js
CHANGED
|
@@ -43,7 +43,7 @@ try {
|
|
|
43
43
|
* applications.
|
|
44
44
|
*
|
|
45
45
|
* Sample commands to run configurations produced by this method include:
|
|
46
|
-
* `webpack --env
|
|
46
|
+
* `webpack --env prodBuild --env appVersion=1.2.3` to trigger a build at version 1.2.3
|
|
47
47
|
* `webpack-dev-server --env inlineHoist` to run dev server w/hoist-react in inline mode
|
|
48
48
|
*
|
|
49
49
|
* @param {Object} env - config passed in from app webpack config or the CLI via --env flags.
|
|
@@ -235,7 +235,9 @@ async function configureWebpack(env) {
|
|
|
235
235
|
// was imported from is different than the instance that was used to render the component
|
|
236
236
|
// (which will always be the instance hoist-react has when using element factories)
|
|
237
237
|
resolveAliases['react'] = path.resolve('./node_modules/react');
|
|
238
|
-
|
|
238
|
+
// Also ensure a single instance of ag-Grid when Hoist is inline, needed to support use of
|
|
239
|
+
// `useGridMenuItem` hook.
|
|
240
|
+
resolveAliases['ag-grid-react'] = path.resolve('./node_modules/ag-grid-react');
|
|
239
241
|
}
|
|
240
242
|
|
|
241
243
|
// When running inline, resolve inline Hoist's own node_modules package so we can tell Babel to exclude
|