@servicetitan/docs-uikit 36.3.1 → 37.0.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.
@@ -1,310 +0,0 @@
1
- ---
2
- title: build
3
- ---
4
-
5
- Build packages for production to the `dist/bundle` folders. It bundles them in production mode and optimizes the build for the best performance. The builds are minified and the filenames include the hashes. Apps are ready to be deployed.
6
-
7
- ## Options
8
-
9
- | Option | Description |
10
- | :----------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
11
- | `--scope <glob>` | Include only packages with names matching the given glob. |
12
- | `--ignore <glob>` | Exclude packages with names matching the given glob. |
13
- | `--cdn-path <url>` | Specify the base path for all the assets within the application. |
14
- | `--stat` | Generate bundle report with [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer). Starting `v22.3.0` works for [MFEs](../microfrontends) too. |
15
- | `--code-coverage` | Add [instrumentation](https://github.com/JS-DevTools/coverage-istanbul-loader) to bundled code in order to collect code coverage |
16
- | `--use-tsc` | Use TSC for TypeScript compilation |
17
-
18
- ## Build Steps
19
-
20
- The `build` command executes these steps:
21
-
22
- 1. Activate Kendo UI license.
23
- 1. Run package **precompile** scripts, if any.
24
- 1. Compile Typescript.
25
- 1. Generate TypeScript definitions from CSS, LESS, and SASS modules, and copy assets and style files to the output folder.
26
- 1. Run type check via [TypeScript project references](https://www.typescriptlang.org/docs/handbook/project-references.html).
27
- 1. Bundle application and MFE packages.
28
-
29
- :::note
30
- `startup` doesn't support dependencies between the Webpack bundles.
31
- :::
32
-
33
- ### Precompile Script
34
-
35
- ✨ New in **v34.0.0** ✨
36
-
37
- The `build` command runs the `precompile` script defined in each package's `package.json` before compiling TypeScript. This allows packages to execute custom setup tasks during the build process. If a package doesn't define a `precompile` script, this step is skipped.
38
-
39
- ## Package Setup
40
-
41
- Because `startup` compiles and builds in separate steps, packages must export compiled Javascript instead of the TypeScript source files. E.g.,
42
-
43
- ```json title="package.json"
44
- {
45
- "exports": "./dist/index.js",
46
- "main": "./dist/index.js",
47
- "typings": "./dist/index.d.ts"
48
- }
49
- ```
50
-
51
- And, to ensure packages are compiled in the correct order, [TypeScript project references](https://www.typescriptlang.org/docs/handbook/project-references.html) must accurately describe the dependencies between packages. E.g.,
52
-
53
- ```json title="tsconfig.json"
54
- {
55
- "references": [
56
- { "path": "../component-a" },
57
- { "path": "../component-b" },
58
- { "path": "../component-c" }
59
- ]
60
- }
61
- ```
62
-
63
- :::note
64
- The Webpack documentation suggests using a configuration that enters through `./src/index.ts`, and using `ts-loader` to process `.ts` and `.tsx` files. However, because `startup` precompiles Typescript, this is redundant and webpack must be configured to load the compiled Javascript.
65
- :::
66
-
67
- ## CSS Modules
68
-
69
- `Startup` supports [CSS Modules](https://github.com/css-modules/css-modules) alongside regular stylesheets using the `[name].module.{css,less,scss}` file naming convention. CSS Modules provide locally scoped class names that prevent global CSS collisions, making styles more predictable and easier to refactor.
70
-
71
- ## SVG Transformation
72
-
73
- By default, SVGs are loaded as assets. Depending on the file size, the asset is converted to a base64 URI string, or emitted as separate file. E.g.,
74
-
75
- ```tsx
76
- import MySVG from './my.svg';
77
-
78
- function MyImage() {
79
- return <img src={MySVG} />;
80
- }
81
- ```
82
-
83
- ### Importing SVGs as React Components
84
-
85
- By default `startup` imports SVGs from `@servicetitan/anvil2` as React components. E.g.,
86
-
87
- ```tsx
88
- import { Button } from '@servicetitan/anvil2';
89
- import CheckIcon from '@servicetitan/anvil2/assets/icons/material/round/check.svg';
90
-
91
- export function CheckButton() {
92
- return <Button icon={CheckIcon} />;
93
- }
94
- ```
95
-
96
- To import SVGs from other sources as React components, append `?component` to the import statement. E.g.,
97
-
98
- ```tsx
99
- import { Button } from '@servicetitan/anvil2';
100
- import CheckIcon from './assets/check.svg?component';
101
-
102
- export function CheckButton() {
103
- return <Button icon={CheckIcon} />;
104
- }
105
- ```
106
-
107
- ### Importing Anvil 2 SVGs as Assets
108
-
109
- By default `startup` imports SVGs from `@servicetitan/anvil2` as React components.
110
- To import an Anvil 2 SVG as an asset, append `?asset` to the import statement. E.g.,
111
-
112
- ```tsx
113
- import CheckIcon from '@servicetitan/anvil2/assets/icons/material/round/check.svg?asset';
114
-
115
- function CheckImage() {
116
- return <img src={CheckIcon} />;
117
- }
118
- ```
119
-
120
- ## Configuration
121
-
122
- ### Library Packages
123
-
124
- Set `cli.webpack` to `false` to disable Webpack for non-application packages, such as component and utility libraries.
125
-
126
- ```json title="package.json"
127
- {
128
- "cli": {
129
- "webpack": false
130
- }
131
- }
132
- ```
133
-
134
- ### Type Checking
135
-
136
- Use package-specific `tsconfig.json` and `tsconfig.build.json` files to set or override type checking options. E.g.,
137
-
138
- ```json title="tsconfig.json"
139
- {
140
- "extends": "@servicetitan/startup/tsconfig/base",
141
- "compilerOptions": {
142
- "outDir": "dist",
143
- "rootDir": "src"
144
- // Other type checking options (https://www.typescriptlang.org/tsconfig/)
145
- },
146
- "include": ["src/**/*"]
147
- }
148
- ```
149
-
150
- Use `tsconfig.build.json` that extends from `tsconfig.json` to exclude tests, stories, and mocks from type checking. E.g.,
151
-
152
- ```json title="tsconfig.build.json"
153
- {
154
- "extends": "./tsconfig.json",
155
- "exclude": ["**/__tests__/*", "**/*.test.*", "**/__mocks__/*", "**/*.stories.*"],
156
- "references": [
157
- { "path": "../feature-a" },
158
- { "path": "../feature-b" },
159
- { "path": "../feature-c" }
160
- ]
161
- }
162
- ```
163
-
164
- :::caution
165
- Project references must be duplicated in `tsconfig.build.json` because [references are not inherited](https://github.com/microsoft/TypeScript/issues/27098).
166
- :::
167
-
168
- ### TypeScript Compilation (SWC)
169
-
170
- :::info
171
- `Startup` only maps a subset of TypeScript settings from `tsconfig.json` to SWC options. See [cliOptions](https://github.com/search?q=repo%3Aservicetitan%2Fuikit+%22cliOptions%3A%22+-path%3A**%2F*.test.ts&type=code) and [swcOptions](https://github.com/search?q=repo%3Aservicetitan%2Fuikit+%22swcOptions%3A%22+-path%3A**%2F*.test.ts&type=code) for the details.
172
- :::
173
-
174
- Use `cli.swc-compile-package` to set or override SWC options. E.g.,
175
-
176
- ```json title="package.json"
177
- {
178
- "cli": {
179
- "swc-compile-package": {
180
- "cliOptions": {
181
- // CLI options (https://swc.rs/docs/usage/cli)
182
- },
183
- "swcOptions": {
184
- // Compilation options (https://swc.rs/docs/configuration/compilation)
185
- // Module options (https://swc.rs/docs/configuration/modules)
186
- }
187
- }
188
- }
189
- }
190
- ```
191
-
192
- ### TypeScript Compilation (TSC)
193
-
194
- :::caution
195
- Compilation via TSC is deprecated.
196
- :::
197
-
198
- Use package-specific `tsconfig.json` and `tsconfig.build.json` files to set or override compiler options. See [Type checking](#type-checking) for more information.
199
-
200
- ### Minimization
201
-
202
- By default `startup` configures webpack to minimize production bundles conservatively,
203
- so that projects gain the benefits of reduced bundle sizes while retaining the highest
204
- fidelity for source map debugging.
205
- It uses [TerserWebpackPlugin](https://webpack.js.org/plugins/terser-webpack-plugin) to minimize JS bundles
206
- and [CssMinimizerWebpackPlugin](https://webpack.js.org/plugins/css-minimizer-webpack-plugin)
207
- to minimize CSS bundles.
208
-
209
- - To turn off minimizing, set `cli.webpack.minify.js` or `cli.webpack.minify.css`, or both, to `false`.
210
- - To override the default Terser options set `cli.webpack.minify.js` to an object containing
211
- [`terserOptions`](https://webpack.js.org/plugins/terser-webpack-plugin/#terseroptions).
212
- - To override the default CssMinimizerWebpackPlugin options, set `cli.webpack.minify.css` to an object containing
213
- [CssMinimizerWebpackPlugin options](https://webpack.js.org/plugins/css-minimizer-webpack-plugin/#options).
214
-
215
- For example,
216
-
217
- ```json title="package.json"
218
- {
219
- "cli": {
220
- "webpack": {
221
- "minify": {
222
- "js": {
223
- // terser-webpack-plugin terserOptions
224
- // https://webpack.js.org/plugins/terser-webpack-plugin/#terseroptions
225
- },
226
- "css": {
227
- // css-minimizer-webpack-plugin options
228
- // https://webpack.js.org/plugins/css-minimizer-webpack-plugin/#options
229
- }
230
- }
231
- }
232
- }
233
- }
234
- ```
235
-
236
- ### Webpack
237
-
238
- To further customize Webpack settings, create files named `webpack.*.config.js` in the package's root directory (the directory with its `package.json`).
239
-
240
- Use `webpack.dev.config.js` to customize development builds and use `webpack.prod.config.js` to customize production builds. In the config file,
241
-
242
- - Import `createWebpackConfig` from `@servicetitan/startup`.
243
- - Call it with the custom Webpack options.
244
- - Return the result as the default export.
245
-
246
- For example, to customize the Webpack's **output** path,
247
-
248
- ```js title="webpack.dev.config.js"
249
- const path = require('path');
250
- const { createWebpackConfig } = require('@servicetitan/startup');
251
-
252
- module.exports = createWebpackConfig({
253
- configuration: {
254
- mode: 'development',
255
- output: { path: path.resolve(__dirname, '../../wwwroot') },
256
- },
257
- });
258
- ```
259
-
260
- :::caution
261
- For MFEs the approach is slightly different, see [Customizing Webpack for MFEs](#customizing-webpack-for-mfes)
262
- :::
263
-
264
- #### createWebpackConfig
265
-
266
- `createWebpackConfig` takes an object with two fields, `configuration` and `plugins`.
267
-
268
- | Field | Description |
269
- | :-------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
270
- | `configuration` | Merged with the defaults to produce the final webpack configuration. For production builds, **configuration.mode** must be set to "production". For development builds, set it to "development". |
271
- | `plugins` | `HtmlWebpackPlugin` and `MiniCssExtractPlugin` subkeys are merged with the default configurations for the corresponding plugins. |
272
-
273
- For example,
274
-
275
- ```js title="webpack.prod.config.js"
276
- const { createWebpackConfig } = require('@servicetitan/startup');
277
-
278
- module.exports = createWebpackConfig({
279
- configuration: {
280
- mode: 'production',
281
- },
282
- plugins: {
283
- HtmlWebpackPlugin: {
284
- favicon: './favicon.ico',
285
- title: 'Enterprise Hub',
286
- },
287
- },
288
- });
289
- ```
290
-
291
- :::caution
292
- Remember, you must set `configuration.mode` to "production" in `webpack.prod.config.js`.
293
- :::
294
-
295
- #### Customizing Webpack for MFEs
296
-
297
- Because `startup` runs Webpack multiple times to create MFEs bundles, a slightly different approach is required for MFEs.
298
- Don't call `createWebpackConfig` and just return an object with the same `configuration` and `plugins` fields described [above](#createwebpackconfig).
299
- E.g.,
300
-
301
- ```js title="webpack.dev.config.js"
302
- const path = require('path');
303
-
304
- module.exports = {
305
- configuration: {
306
- mode: 'development',
307
- output: { path: path.resolve(__dirname, '../../wwwroot') },
308
- },
309
- };
310
- ```
@@ -1,73 +0,0 @@
1
- ---
2
- title: start
3
- ---
4
-
5
- Serves applications and [MFEs](../microfrontends) during development, watches source files, and automatically reloads pages on changes.
6
-
7
- :::tip
8
- To serve an application without `start`, [build](./build) it, then point any static http server to the output **bundle** directory, where the browser will find `index.html`. For example, to serve with [`http-server`](https://www.npmjs.com/package/http-server)
9
-
10
- ```sh
11
- npx -yes http-server packages/application/dist/bundle
12
- ```
13
-
14
- :::
15
-
16
- ## Options
17
-
18
- | Option | Description |
19
- | :---------------- | :------------------------------------------------------------------------------------------------------------------------------- |
20
- | `--scope <glob>` | Include only packages with names matching the given glob. |
21
- | `--ignore <glob>` | Exclude packages with names matching the given glob. |
22
- | `--code-coverage` | Add [instrumentation](https://github.com/JS-DevTools/coverage-istanbul-loader) to bundled code in order to collect code coverage |
23
- | `--use-tsc` | Use TSC for TypeScript compilation |
24
-
25
- ## Start Steps
26
-
27
- The `start` command executes the same steps as the `build` command, then watches for changes and automatically reruns each step as needed.
28
-
29
- See [Build Steps](./build#build-steps).
30
-
31
- ## Configuration
32
-
33
- ### Port
34
-
35
- Use `cli.webpack.port` to select the port to use for a package. By default, packages are served from the first available port starting from 8080.
36
-
37
- ```json title="package.json"
38
- {
39
- "cli": {
40
- "webpack": {
41
- "port": 8888
42
- }
43
- }
44
- }
45
- ```
46
-
47
- ✨ New in **v35.2.0** ✨
48
-
49
- You can also override the port at runtime using the `PORT` environment variable. This takes precedence over `cli.webpack.port` and is useful for tools like .NET Aspire that need to assign dynamic ports.
50
-
51
- ```bash
52
- PORT=3000 npm start
53
- ```
54
-
55
- ### DevServer
56
-
57
- Use `cli.webpack.devServer` to set or override `webpack-dev-server` options.
58
-
59
- ```json title="package.json"
60
- {
61
- "cli": {
62
- "webpack": {
63
- "devServer": {
64
- // webpack-dev-server options (https://webpack.js.org/configuration/dev-server/#devserver)
65
- }
66
- }
67
- }
68
- }
69
- ```
70
-
71
- :::tip
72
- Set `cli.webpack.devServer` to `false` to disable `webpack-dev-server` altogether.
73
- :::