@servicetitan/docs-uikit 36.0.0 → 36.1.1-beta.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.
@@ -19,7 +19,7 @@ sidebar_position: 0
19
19
 
20
20
  ### [@servicetitan/launchdarkly-service](./launchdarkly-service.mdx)
21
21
 
22
- - Added `mobx-react` peer dependency. If your project does not already depend on `mobx-react`, add version `~9.2.0`.
22
+ - Added `mobx-react` peer dependency. If your project does not already depend on `mobx-react`, add version `~9.2.0`.
23
23
 
24
24
  ## v34.0.0
25
25
 
@@ -46,7 +46,7 @@ This breaking change affects local development, even if you do not update the `@
46
46
 
47
47
  Removed support for hard-coded npm tokens in `.npmrc` files. The new `startup install` removes hard-coded authentication tokens from project `.npmrc` files and, in development environments, automatically adds a token to npm's per-user configuration that grants access to ServiceTitan's private packages.
48
48
 
49
- Projects that previously relied on hard-coded tokens must update their Github and Teamcity workflows to instead use the organization secret as described in the [startup install documentation](./startup/install#configuring-npm-token-in-ci):
49
+ Projects that previously relied on hard-coded tokens must update their Github and Teamcity workflows to instead use the organization secret as described in the [startup install documentation](./install#configuring-npm-token-in-ci):
50
50
 
51
51
  - Option 1: Inject the organization secret into `.npmrc`.
52
52
  - Option 2: Configure `.npmrc` to get the organization secret from an environment variable.
@@ -42,7 +42,7 @@ export const DispatchModule: React.FC = () => <LazyDispatch />;
42
42
  | :----------------------- | :---------------------------------------- | :----------------------------------------------------------------- | :------------------------------------------------------------- |
43
43
  | `loader` | `() => Promise<React.ComponentType<any>>` | Function doing dynamic import of a module | Yes |
44
44
  | `name` | `string` | Module name | Yes |
45
- | `loadingComponent` | `React.ComponentType<any>` | Component to display while loading is in progress | No, defaults to `DefaultLoading` |
45
+ | `loadingComponent` | `React.ComponentType<any>` | Component to display while loading is in progress | No, defaults to `DefaultLoading` |
46
46
  | `loadingErrorComponent` | `React.ComponentType<any>` | Component to display if module loading fails | No, defaults to `DefaultLoadingError` |
47
47
  | `errorFallbackComponent` | `React.ComponentType<any>` | Component to pass to `@servicetitan/error-boundary` module wrapper | No, uses default component from `@servicetitan/error-boundary` |
48
48
 
@@ -6,7 +6,7 @@ A host is an application, or MFE, that uses [`Loader`](../web-components/loader)
6
6
 
7
7
  ## Configuration
8
8
 
9
- Set `cli.webpack.expose-shared-dependencies` to `true` in the application's `package.json`.
9
+ Set `cli.expose-shared-dependencies` to `true` in the application's `package.json`.
10
10
 
11
11
  :::caution
12
12
  `expose-shared-dependencies` only applies to applications. MFEs that load other MFEs do not need this setting or any additional configuration.
@@ -15,13 +15,15 @@ Set `cli.webpack.expose-shared-dependencies` to `true` in the application's `pac
15
15
  ```json title="package.json"
16
16
  {
17
17
  "cli": {
18
- "webpack": {
19
- "expose-shared-dependencies": true
20
- }
18
+ "expose-shared-dependencies": true
21
19
  }
22
20
  }
23
21
  ```
24
22
 
23
+ :::note
24
+ In versions before **[INSERT-VERSION-HERE]**, this setting was under `cli.webpack.expose-shared-dependencies`. The old location still works for backward compatibility.
25
+ :::
26
+
25
27
  ### Design system
26
28
 
27
29
  If the host uses `@servicetitan/design-system` remove all imports of design system styles from the code; `startup` handles that automatically. Alternatively, to customize the design system styles, move the imports to a file named `design-system.css` in the root directory of the application's source folder (the `rootDir` in `tsconfig.json`). E.g.,
@@ -27,7 +27,11 @@ By default, MFEs and hosts share the following dependencies (see [here](https://
27
27
  MFE's are not required to use all the default dependencies; `startup` and `Loader` ignore any that aren't used.
28
28
  :::
29
29
 
30
- To customize which dependencies are shared, set `cli.webpack.shared-dependencies` to an object that maps dependencies to `SharedDependencies.{name}`. By convention `{name}` is the camel-cased package name.
30
+ To customize which dependencies are shared, set `cli.shared-dependencies` to an object that maps dependencies to `SharedDependencies.{name}`. By convention `{name}` is the camel-cased package name.
31
+
32
+ :::note
33
+ In versions before **[INSERT-VERSION-HERE]**, this setting was under `cli.webpack.shared-dependencies`. The old location still works for backward compatibility.
34
+ :::
31
35
 
32
36
  - Use the special **defaults** key with the empty string to incorporate the default list.
33
37
  - To exclude a default dependency, map it to the empty string.
@@ -39,11 +43,9 @@ To add a dependency, use the special **defaults** key to first include the defau
39
43
  ```json title="package.json"
40
44
  {
41
45
  "cli": {
42
- "webpack": {
43
- "shared-dependencies": {
44
- "defaults": "", // add default list
45
- "lodash": "SharedDependencies.Lodash" // add lodash
46
- }
46
+ "shared-dependencies": {
47
+ "defaults": "", // add default list
48
+ "lodash": "SharedDependencies.Lodash" // add lodash
47
49
  }
48
50
  }
49
51
  }
@@ -65,11 +67,9 @@ To omit an default dependency, map it to the empty string. For example, to omit
65
67
  ```json title="package.json"
66
68
  {
67
69
  "cli": {
68
- "webpack": {
69
- "shared-dependencies": {
70
- "defaults": "", // add default list
71
- "@servicetitan/design-system": "" // drop @servicetitan/design-system
72
- }
70
+ "shared-dependencies": {
71
+ "defaults": "", // add default list
72
+ "@servicetitan/design-system": "" // drop @servicetitan/design-system
73
73
  }
74
74
  }
75
75
  }
@@ -82,12 +82,10 @@ To completely customize the list of shared dependencies, omit the **defaults** k
82
82
  ```json title="package.json"
83
83
  {
84
84
  "cli": {
85
- "webpack": {
86
- "shared-dependencies": {
87
- "@servicetitan/anvil2": "SharedDependencies.ServiceTitan.Anvil2",
88
- "react": "SharedDependencies.React",
89
- "react-dom": "SharedDependencies.ReactDOM"
90
- }
85
+ "shared-dependencies": {
86
+ "@servicetitan/anvil2": "SharedDependencies.ServiceTitan.Anvil2",
87
+ "react": "SharedDependencies.React",
88
+ "react-dom": "SharedDependencies.ReactDOM"
91
89
  }
92
90
  }
93
91
  }
@@ -0,0 +1,199 @@
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
+ `startup` supports two bundlers: [Webpack](./webpack) (default) and [Vite](./vite) (opt-in via `--use-vite`).
8
+
9
+ ## Options
10
+
11
+ | Option | Webpack | Vite | Description |
12
+ | :----------------- | :------ | :------ | :--------------------------------------------------------------------------------- |
13
+ | `--scope <glob>` | Yes | Yes | Include only packages with names matching the given glob. |
14
+ | `--ignore <glob>` | Yes | Yes | Exclude packages with names matching the given glob. |
15
+ | `--cdn-path <url>` | Yes | Planned | Specify the base path for all the assets within the application. |
16
+ | `--stat` | Yes | Planned | Generate bundle analysis report. |
17
+ | `--code-coverage` | Yes | Planned | Add instrumentation to bundled code in order to collect code coverage. |
18
+ | `--use-tsc` | Yes | Yes | Use TSC for TypeScript compilation. |
19
+ | `--use-vite` | No | Yes | ✨ **[INSERT-VERSION-HERE]** Use Vite instead of webpack. |
20
+ | `--preview` | No | Yes | ✨ **[INSERT-VERSION-HERE]** Preview production build locally via a static server. |
21
+ | `--config <path>` | Yes | No | Custom config file path. Vite uses convention-based config files instead. |
22
+
23
+ ## Build Steps
24
+
25
+ The `build` command executes these steps:
26
+
27
+ 1. Activate Kendo UI license.
28
+ 1. Run package **precompile** scripts, if any.
29
+ 1. Compile Typescript.
30
+ 1. Generate TypeScript definitions from CSS, LESS, and SASS modules, and copy assets and style files to the output folder.
31
+ 1. Run type check via [TypeScript project references](https://www.typescriptlang.org/docs/handbook/project-references.html).
32
+ 1. Bundle application and MFE packages.
33
+
34
+ ### Precompile Script
35
+
36
+ ✨ New in **v34.0.0** ✨
37
+
38
+ 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.
39
+
40
+ ## Package Setup
41
+
42
+ Because `startup` compiles and builds in separate steps, packages must export compiled Javascript instead of the TypeScript source files. E.g.,
43
+
44
+ ```json title="package.json"
45
+ {
46
+ "exports": "./dist/index.js",
47
+ "main": "./dist/index.js",
48
+ "typings": "./dist/index.d.ts"
49
+ }
50
+ ```
51
+
52
+ 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.,
53
+
54
+ ```json title="tsconfig.json"
55
+ {
56
+ "references": [
57
+ { "path": "../component-a" },
58
+ { "path": "../component-b" },
59
+ { "path": "../component-c" }
60
+ ]
61
+ }
62
+ ```
63
+
64
+ ## CSS Modules
65
+
66
+ `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.
67
+
68
+ ## SVG Transformation
69
+
70
+ 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.,
71
+
72
+ ```tsx
73
+ import MySVG from './my.svg';
74
+
75
+ function MyImage() {
76
+ return <img src={MySVG} />;
77
+ }
78
+ ```
79
+
80
+ ### Importing SVGs as React Components
81
+
82
+ By default `startup` imports SVGs from `@servicetitan/anvil2` as React components. E.g.,
83
+
84
+ ```tsx
85
+ import { Button } from '@servicetitan/anvil2';
86
+ import CheckIcon from '@servicetitan/anvil2/assets/icons/material/round/check.svg';
87
+
88
+ export function CheckButton() {
89
+ return <Button icon={CheckIcon} />;
90
+ }
91
+ ```
92
+
93
+ To import SVGs from other sources as React components, append `?component` to the import statement. E.g.,
94
+
95
+ ```tsx
96
+ import { Button } from '@servicetitan/anvil2';
97
+ import CheckIcon from './assets/check.svg?component';
98
+
99
+ export function CheckButton() {
100
+ return <Button icon={CheckIcon} />;
101
+ }
102
+ ```
103
+
104
+ ### Importing Anvil 2 SVGs as Assets
105
+
106
+ By default `startup` imports SVGs from `@servicetitan/anvil2` as React components.
107
+ To import an Anvil 2 SVG as an asset, append `?asset` to the import statement. E.g.,
108
+
109
+ ```tsx
110
+ import CheckIcon from '@servicetitan/anvil2/assets/icons/material/round/check.svg?asset';
111
+
112
+ function CheckImage() {
113
+ return <img src={CheckIcon} />;
114
+ }
115
+ ```
116
+
117
+ ## Configuration
118
+
119
+ ### Library Packages
120
+
121
+ Set `cli.webpack` or `cli.vite` to `false` to disable bundling for non-application packages, such as component and utility libraries.
122
+
123
+ ```json title="package.json"
124
+ {
125
+ "cli": {
126
+ "webpack": false
127
+ }
128
+ }
129
+ ```
130
+
131
+ ### Type Checking
132
+
133
+ Use package-specific `tsconfig.json` and `tsconfig.build.json` files to set or override type checking options. E.g.,
134
+
135
+ ```json title="tsconfig.json"
136
+ {
137
+ "extends": "@servicetitan/startup/tsconfig/base",
138
+ "compilerOptions": {
139
+ "outDir": "dist",
140
+ "rootDir": "src"
141
+ // Other type checking options (https://www.typescriptlang.org/tsconfig/)
142
+ },
143
+ "include": ["src/**/*"]
144
+ }
145
+ ```
146
+
147
+ Use `tsconfig.build.json` that extends from `tsconfig.json` to exclude tests, stories, and mocks from type checking. E.g.,
148
+
149
+ ```json title="tsconfig.build.json"
150
+ {
151
+ "extends": "./tsconfig.json",
152
+ "exclude": ["**/__tests__/*", "**/*.test.*", "**/__mocks__/*", "**/*.stories.*"],
153
+ "references": [
154
+ { "path": "../feature-a" },
155
+ { "path": "../feature-b" },
156
+ { "path": "../feature-c" }
157
+ ]
158
+ }
159
+ ```
160
+
161
+ :::caution
162
+ Project references must be duplicated in `tsconfig.build.json` because [references are not inherited](https://github.com/microsoft/TypeScript/issues/27098).
163
+ :::
164
+
165
+ ### TypeScript Compilation (SWC)
166
+
167
+ :::info
168
+ `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.
169
+ :::
170
+
171
+ Use `cli.swc-compile-package` to set or override SWC options. E.g.,
172
+
173
+ ```json title="package.json"
174
+ {
175
+ "cli": {
176
+ "swc-compile-package": {
177
+ "cliOptions": {
178
+ // CLI options (https://swc.rs/docs/usage/cli)
179
+ },
180
+ "swcOptions": {
181
+ // Compilation options (https://swc.rs/docs/configuration/compilation)
182
+ // Module options (https://swc.rs/docs/configuration/modules)
183
+ }
184
+ }
185
+ }
186
+ }
187
+ ```
188
+
189
+ ### TypeScript Compilation (TSC)
190
+
191
+ :::caution
192
+ Compilation via TSC is deprecated.
193
+ :::
194
+
195
+ Use package-specific `tsconfig.json` and `tsconfig.build.json` files to set or override compiler options. See [Type checking](#type-checking) for more information.
196
+
197
+ ### Bundler-Specific Configuration
198
+
199
+ See [Webpack](./webpack) or [Vite](./vite) for bundler-specific configuration options, including minimization, custom config files, and plugin overrides.
@@ -0,0 +1,255 @@
1
+ ---
2
+ title: Vite
3
+ ---
4
+
5
+ ✨ New in **[INSERT-VERSION-HERE]** ✨
6
+
7
+ Vite is an alternative bundler for `startup build`, enabled with the `--use-vite` flag. It uses [Vite](https://vite.dev/) with the [Rolldown](https://rolldown.rs/) bundler and [OXC](https://oxc.rs/) minifier/transformer.
8
+
9
+ ```sh
10
+ npx startup build --use-vite
11
+ ```
12
+
13
+ :::tip
14
+ For dev server configuration (port, proxy, HMR), see [Vite start](../start/vite).
15
+ :::
16
+
17
+ ## Configuration Priority
18
+
19
+ Vite configuration comes from three sources, merged in order (later wins):
20
+
21
+ 1. **Startup defaults**: base config built by startup
22
+ 2. **`cli.vite` in package.json**: serializable overrides
23
+ 3. **Config file** (`vite.dev.config.ts` / `vite.prod.config.ts`): full Vite config via [`defineConfig`](#config-files-defineconfig)
24
+
25
+ ## Configuration Shortcuts
26
+
27
+ Shortcuts are convenience options available in both `cli.vite` (package.json) and config files. They map to multiple Vite config values internally.
28
+
29
+ | Shortcut | Type | Description |
30
+ | :---------------- | :----------------- | :------------------------------------ |
31
+ | `omitDefault` | `string[]` | Remove default config keys or plugins |
32
+ | `minify` | `{ js?, css? }` | Toggle JS/CSS minification (OXC) |
33
+ | `pluginOverrides` | `{ html?, svgr? }` | Override default plugin options |
34
+
35
+ ### `omitDefault`
36
+
37
+ List of config keys or plugin names to remove from startup's defaults. Plugin names are prefixed with `plugins.`.
38
+
39
+ ```json title="package.json"
40
+ {
41
+ "cli": {
42
+ "vite": {
43
+ "omitDefault": ["plugins.svgr", "css"]
44
+ }
45
+ }
46
+ }
47
+ ```
48
+
49
+ ### `minify`
50
+
51
+ Control JS and CSS minification independently. Default: OXC minifier for both JS and CSS in production builds.
52
+
53
+ ```json title="package.json"
54
+ {
55
+ "cli": {
56
+ "vite": {
57
+ "minify": {
58
+ "js": false,
59
+ "css": false
60
+ }
61
+ }
62
+ }
63
+ }
64
+ ```
65
+
66
+ ### `pluginOverrides`
67
+
68
+ Override options for startup's built-in plugins.
69
+
70
+ #### `html`
71
+
72
+ | Option | Type | Default | Description |
73
+ | :--------- | :------- | :---------------- | :----------------------------------------------------- |
74
+ | `title` | `string` | `'ServiceTitan'` | Page title in `<title>` tag |
75
+ | `favicon` | `string` | `'favicon.ico'` | Path to favicon, relative to project root |
76
+ | `template` | `string` | built-in template | Path to custom HTML template using eta template syntax |
77
+
78
+ #### `svgr`
79
+
80
+ | Option | Type | Description |
81
+ | :------------ | :--------------------------------------------------- | :--------------------------------- |
82
+ | `include` | `string \| string[]` | Glob patterns to include for SVGR |
83
+ | `exclude` | `string \| string[]` | Glob patterns to exclude from SVGR |
84
+ | `svgrOptions` | [`SvgrConfig`](https://react-svgr.com/docs/options/) | Options passed to SVGR transformer |
85
+
86
+ ## Vite Config (`cli.vite.config`)
87
+
88
+ For direct Vite configuration, use `cli.vite.config` in package.json. It accepts Vite's [`UserConfig`](https://vite.dev/config/) shape, minus `plugins` (not serializable in JSON).
89
+
90
+ ```json title="package.json"
91
+ {
92
+ "cli": {
93
+ "vite": {
94
+ "config": {
95
+ "build": {
96
+ "target": "es2020"
97
+ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+ ```
103
+
104
+ ## Config Files (`defineConfig`)
105
+
106
+ For advanced configuration, create `vite.dev.config.ts` (development) or `vite.prod.config.ts` (production) in the package root. Config files support full Vite `UserConfig` including `plugins`.
107
+
108
+ Import `defineConfig` from `@servicetitan/startup/vite` for type safety:
109
+
110
+ ```ts title="vite.prod.config.ts"
111
+ import { defineConfig } from '@servicetitan/startup/vite';
112
+
113
+ export default defineConfig({
114
+ config: {
115
+ build: {
116
+ target: 'es2020',
117
+ },
118
+ },
119
+ pluginOverrides: {
120
+ html: {
121
+ title: 'My App',
122
+ favicon: '/brand.ico',
123
+ },
124
+ },
125
+ });
126
+ ```
127
+
128
+ ### Dynamic Config with Build Context
129
+
130
+ Pass a function to `defineConfig` to access the build context:
131
+
132
+ ```ts title="vite.prod.config.ts"
133
+ import { defineConfig } from '@servicetitan/startup/vite';
134
+
135
+ export default defineConfig(context => {
136
+ // context.build — { name, isProduction, light, headless }
137
+ // context.package — { destination, isWebComponent, sharedDependencies, ... }
138
+ // context.options (coming soon)
139
+
140
+ return {
141
+ config: { ... },
142
+ };
143
+ });
144
+ ```
145
+
146
+ :::tip
147
+ `.js` config files are also supported (`vite.dev.config.js` / `vite.prod.config.js`).
148
+ :::
149
+
150
+ :::tip
151
+ For full mutation access to the resolved config, add a Vite plugin with `enforce: 'post'` and a `config` hook as an escape hatch.
152
+
153
+ ```ts title="vite.prod.config.ts"
154
+ import { defineConfig } from '@servicetitan/startup/vite';
155
+
156
+ export default defineConfig({
157
+ config: {
158
+ plugins: [
159
+ {
160
+ name: 'custom-config-override',
161
+ enforce: 'post',
162
+ config(resolved) {
163
+ resolved.build ??= {};
164
+ resolved.build.chunkSizeWarningLimit = 1000;
165
+ },
166
+ },
167
+ ],
168
+ },
169
+ });
170
+ ```
171
+
172
+ :::
173
+
174
+ ## Custom HTML Templates
175
+
176
+ The HTML plugin uses [eta](https://eta.js.org/) as the template engine. Configure a custom template via `pluginOverrides.html.template`:
177
+
178
+ ```json title="package.json"
179
+ {
180
+ "cli": {
181
+ "vite": {
182
+ "pluginOverrides": {
183
+ "html": {
184
+ "title": "My App",
185
+ "favicon": "/brand.ico",
186
+ "template": "./src/index.html"
187
+ }
188
+ }
189
+ }
190
+ }
191
+ }
192
+ ```
193
+
194
+ Example eta template:
195
+
196
+ ```html title="src/index.html"
197
+ <!doctype html>
198
+ <html>
199
+ <head>
200
+ <meta charset="utf-8" />
201
+ <title><%= it.title %></title>
202
+ <link rel="icon" href="<%= it.favicon %>" />
203
+ <% it.css.forEach(function(item) { %>
204
+ <link href="./<%= item %>" rel="stylesheet" />
205
+ <% }); %> <% it.js.forEach(function(item) { %>
206
+ <script src="./<%= item %>"></script>
207
+ <% }); %>
208
+ </head>
209
+ <body>
210
+ <div id="root"></div>
211
+ <script type="module">
212
+ import './dist/index';
213
+ </script>
214
+ </body>
215
+ </html>
216
+ ```
217
+
218
+ :::tip
219
+ See [startup's default template](https://github.com/servicetitan/uikit/blob/master/packages/startup/src/vite/index.html) for a full working example, including MFE self-hosting and custom-element rendering.
220
+ :::
221
+
222
+ Available template variables:
223
+
224
+ | Variable | Type | Description |
225
+ | :--------------- | :--------- | :---------------------------------------------------------- |
226
+ | `title` | `string` | Page title from `pluginOverrides.html.title` |
227
+ | `favicon` | `string` | Favicon URL (explicit or auto-detected); may be `undefined` |
228
+ | `css` | `string[]` | Stylesheet entry paths to inject as `<link>` tags |
229
+ | `js` | `string[]` | Script entry paths to inject as `<script>` tags |
230
+ | `name` | `string` | Package/MFE name |
231
+ | `isProduction` | `boolean` | True for production builds |
232
+ | `isWebComponent` | `boolean` | True when building an MFE (web component) |
233
+
234
+ Use `<%= %>` for escaped output and `<%~ %>` for unescaped. See the [Eta docs](https://eta.js.org/) for the full template language reference, including conditionals, loops, and partials.
235
+
236
+ ## Preview Server
237
+
238
+ Use the `--preview` flag to start preview servers for all bundled packages after a production build. Each package serves its built bundle from its output directory on its configured dev server port, opening the browser automatically.
239
+
240
+ Unlike `startup start`, preview servers serve only the built static assets: no source transformation, no hot reloading.
241
+
242
+ ```sh
243
+ npx startup build --use-vite --preview
244
+ ```
245
+
246
+ The preview server is useful for validating production builds locally before deploying.
247
+
248
+ ## Not Yet Supported
249
+
250
+ The following features are planned but not yet available with the Vite bundler:
251
+
252
+ - `--stat`: bundle analysis report
253
+ - `--code-coverage`: code instrumentation for coverage
254
+ - `--cdn-path`: CDN public path
255
+ - Storybook configuration
@@ -0,0 +1,117 @@
1
+ ---
2
+ title: Webpack
3
+ ---
4
+
5
+ Webpack is the default bundler for `startup build`.
6
+
7
+ ## Minimization
8
+
9
+ By default `startup` configures webpack to minimize production bundles conservatively,
10
+ so that projects gain the benefits of reduced bundle sizes while retaining the highest
11
+ fidelity for source map debugging.
12
+ It uses [TerserWebpackPlugin](https://webpack.js.org/plugins/terser-webpack-plugin) to minimize JS bundles
13
+ and [CssMinimizerWebpackPlugin](https://webpack.js.org/plugins/css-minimizer-webpack-plugin)
14
+ to minimize CSS bundles.
15
+
16
+ - To turn off minimizing, set `cli.webpack.minify.js` or `cli.webpack.minify.css`, or both, to `false`.
17
+ - To override the default Terser options set `cli.webpack.minify.js` to an object containing
18
+ [`terserOptions`](https://webpack.js.org/plugins/terser-webpack-plugin/#terseroptions).
19
+ - To override the default CssMinimizerWebpackPlugin options, set `cli.webpack.minify.css` to an object containing
20
+ [CssMinimizerWebpackPlugin options](https://webpack.js.org/plugins/css-minimizer-webpack-plugin/#options).
21
+
22
+ For example,
23
+
24
+ ```json title="package.json"
25
+ {
26
+ "cli": {
27
+ "webpack": {
28
+ "minify": {
29
+ "js": {
30
+ // terser-webpack-plugin terserOptions
31
+ // https://webpack.js.org/plugins/terser-webpack-plugin/#terseroptions
32
+ },
33
+ "css": {
34
+ // css-minimizer-webpack-plugin options
35
+ // https://webpack.js.org/plugins/css-minimizer-webpack-plugin/#options
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ```
42
+
43
+ ## Custom Configuration
44
+
45
+ To further customize Webpack settings, create files named `webpack.*.config.js` in the package's root directory (the directory with its `package.json`).
46
+
47
+ Use `webpack.dev.config.js` to customize development builds and use `webpack.prod.config.js` to customize production builds. In the config file,
48
+
49
+ - Import `createWebpackConfig` from `@servicetitan/startup`.
50
+ - Call it with the custom Webpack options.
51
+ - Return the result as the default export.
52
+
53
+ For example, to customize the Webpack's **output** path,
54
+
55
+ ```js title="webpack.dev.config.js"
56
+ const path = require('path');
57
+ const { createWebpackConfig } = require('@servicetitan/startup');
58
+
59
+ module.exports = createWebpackConfig({
60
+ configuration: {
61
+ mode: 'development',
62
+ output: { path: path.resolve(__dirname, '../../wwwroot') },
63
+ },
64
+ });
65
+ ```
66
+
67
+ :::caution
68
+ For MFEs the approach is slightly different, see [Customizing Webpack for MFEs](#customizing-webpack-for-mfes)
69
+ :::
70
+
71
+ ### createWebpackConfig
72
+
73
+ `createWebpackConfig` takes an object with two fields, `configuration` and `plugins`.
74
+
75
+ | Field | Description |
76
+ | :-------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
77
+ | `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". |
78
+ | `plugins` | `HtmlWebpackPlugin` and `MiniCssExtractPlugin` subkeys are merged with the default configurations for the corresponding plugins. |
79
+
80
+ For example,
81
+
82
+ ```js title="webpack.prod.config.js"
83
+ const { createWebpackConfig } = require('@servicetitan/startup');
84
+
85
+ module.exports = createWebpackConfig({
86
+ configuration: {
87
+ mode: 'production',
88
+ },
89
+ plugins: {
90
+ HtmlWebpackPlugin: {
91
+ favicon: './favicon.ico',
92
+ title: 'Enterprise Hub',
93
+ },
94
+ },
95
+ });
96
+ ```
97
+
98
+ :::caution
99
+ Remember, you must set `configuration.mode` to "production" in `webpack.prod.config.js`.
100
+ :::
101
+
102
+ ### Customizing Webpack for MFEs
103
+
104
+ Because `startup` runs Webpack multiple times to create MFEs bundles, a slightly different approach is required for MFEs.
105
+ Don't call `createWebpackConfig` and just return an object with the same `configuration` and `plugins` fields described [above](#createwebpackconfig).
106
+ E.g.,
107
+
108
+ ```js title="webpack.dev.config.js"
109
+ const path = require('path');
110
+
111
+ module.exports = {
112
+ configuration: {
113
+ mode: 'development',
114
+ output: { path: path.resolve(__dirname, '../../wwwroot') },
115
+ },
116
+ };
117
+ ```
@@ -0,0 +1,48 @@
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
+ `startup` supports two bundlers for development: [Webpack](./webpack) (default) and [Vite](./vite) (opt-in via `--use-vite`).
8
+
9
+ :::tip
10
+ 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)
11
+
12
+ ```sh
13
+ npx -yes http-server packages/application/dist/bundle
14
+ ```
15
+
16
+ :::
17
+
18
+ ## Options
19
+
20
+ | Option | Webpack | Vite | Description |
21
+ | :---------------- | :------ | :------ | :--------------------------------------------------------------------- |
22
+ | `--scope <glob>` | Yes | Yes | Include only packages with names matching the given glob. |
23
+ | `--ignore <glob>` | Yes | Yes | Exclude packages with names matching the given glob. |
24
+ | `--code-coverage` | Yes | Planned | Add instrumentation to bundled code in order to collect code coverage. |
25
+ | `--use-tsc` | Yes | Yes | Use TSC for TypeScript compilation. |
26
+ | `--use-vite` | No | Yes | ✨ **[INSERT-VERSION-HERE]** Use Vite instead of webpack. |
27
+
28
+ ## Start Steps
29
+
30
+ The `start` command executes the same steps as the `build` command, then watches for changes and automatically reruns each step as needed.
31
+
32
+ See [Build Steps](../build#build-steps).
33
+
34
+ ## Port
35
+
36
+ The dev server port can be configured per-bundler in `package.json`. See [Webpack](./webpack#port) or [Vite](./vite#port) for details.
37
+
38
+ ✨ New in **v35.2.0** ✨
39
+
40
+ You can also override the port at runtime using the `PORT` environment variable. This takes precedence over bundler-specific port configuration and is useful for tools like .NET Aspire that need to assign dynamic ports.
41
+
42
+ ```bash
43
+ PORT=3000 npm start
44
+ ```
45
+
46
+ ## Configuration
47
+
48
+ See [Webpack](./webpack) or [Vite](./vite) for bundler-specific dev server configuration.
@@ -0,0 +1,90 @@
1
+ ---
2
+ title: Vite
3
+ ---
4
+
5
+ ✨ New in **[INSERT-VERSION-HERE]** ✨
6
+
7
+ Vite is an alternative dev server for `startup start`, enabled with the `--use-vite` flag.
8
+
9
+ ```sh
10
+ npx startup start --use-vite
11
+ ```
12
+
13
+ :::tip
14
+ For build-time configuration (minification, plugin overrides, custom templates), see [Vite build](../build/vite).
15
+ :::
16
+
17
+ ## Server Options
18
+
19
+ ### Port {#port}
20
+
21
+ Use `cli.vite.port` to select the port for the dev server. Default: 8080 for applications, 8888 for MFEs.
22
+
23
+ ```json title="package.json"
24
+ {
25
+ "cli": {
26
+ "vite": {
27
+ "port": 3000
28
+ }
29
+ }
30
+ }
31
+ ```
32
+
33
+ ### Proxy
34
+
35
+ Configure a dev server proxy in `vite.dev.config.ts`:
36
+
37
+ ```ts title="vite.dev.config.ts"
38
+ import { defineConfig } from '@servicetitan/startup/vite';
39
+
40
+ export default defineConfig({
41
+ config: {
42
+ server: {
43
+ proxy: {
44
+ '/api': {
45
+ target: 'http://localhost:3000',
46
+ changeOrigin: true,
47
+ },
48
+ },
49
+ },
50
+ },
51
+ });
52
+ ```
53
+
54
+ For advanced use cases like request interception, use the `configure` callback:
55
+
56
+ ```ts title="vite.dev.config.ts"
57
+ import { defineConfig } from '@servicetitan/startup/vite';
58
+
59
+ export default defineConfig({
60
+ config: {
61
+ server: {
62
+ proxy: {
63
+ '/api': {
64
+ target: 'http://localhost:3000',
65
+ configure: proxy => {
66
+ proxy.on('proxyReq', (proxyReq, req) => {
67
+ proxyReq.setHeader('X-Custom-Header', 'value');
68
+ });
69
+ },
70
+ },
71
+ },
72
+ },
73
+ },
74
+ });
75
+ ```
76
+
77
+ See [Vite server.proxy](https://vite.dev/config/server-options#server-proxy) for the full list of options.
78
+
79
+ ## Hot Module Replacement
80
+
81
+ Vite provides fast HMR out of the box. CSS changes are applied instantly without a full page reload.
82
+
83
+ For MFEs running in shadow DOM, CSS HMR uses `adoptedStyleSheets`. Style updates are applied to the shadow root automatically without affecting the host page.
84
+
85
+ ## Not Yet Supported
86
+
87
+ The following webpack dev server features are not yet available with Vite:
88
+
89
+ - `--code-coverage`: code instrumentation for coverage
90
+ - `cli.webpack.devServer: false` equivalent: disabling the dev server to use file watching + rebuild to disk instead.
@@ -0,0 +1,39 @@
1
+ ---
2
+ title: Webpack
3
+ ---
4
+
5
+ Webpack is the default bundler for `startup start`.
6
+
7
+ ## Port {#port}
8
+
9
+ 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.
10
+
11
+ ```json title="package.json"
12
+ {
13
+ "cli": {
14
+ "webpack": {
15
+ "port": 8888
16
+ }
17
+ }
18
+ }
19
+ ```
20
+
21
+ ## DevServer
22
+
23
+ Use `cli.webpack.devServer` to set or override `webpack-dev-server` options.
24
+
25
+ ```json title="package.json"
26
+ {
27
+ "cli": {
28
+ "webpack": {
29
+ "devServer": {
30
+ // webpack-dev-server options (https://webpack.js.org/configuration/dev-server/#devserver)
31
+ }
32
+ }
33
+ }
34
+ }
35
+ ```
36
+
37
+ :::tip
38
+ Set `cli.webpack.devServer` to `false` to disable `webpack-dev-server` altogether.
39
+ :::
@@ -2,6 +2,9 @@
2
2
  title: Startup
3
3
  ---
4
4
 
5
+ import Tabs from '@theme/Tabs';
6
+ import TabItem from '@theme/TabItem';
7
+
5
8
  #### [CHANGELOG (@servicetitan/startup)](https://github.com/servicetitan/uikit/blob/master/packages/startup/CHANGELOG.md)
6
9
 
7
10
  [@servicetitan/startup](https://github.com/servicetitan/uikit/tree/master/packages/startup) is a command-line interface (CLI) to create multi-package Lerna projects with the support of TypeScript Project References and React. It offers a modern build setup with no configuration.
@@ -20,6 +23,19 @@ It's overwhelming how many development dependencies are required to work with th
20
23
 
21
24
  Updating build tooling is typically a daunting and time-consuming task. When new versions of [@servicetitan/startup](https://github.com/servicetitan/uikit/tree/master/packages/startup) are released, you just need to bump its version.
22
25
 
26
+ ## Bundlers
27
+
28
+ `startup` supports two bundlers:
29
+
30
+ - **Webpack** — the default bundler.
31
+ - **Vite** — opt-in via `--use-vite` (✨ New in **[INSERT-VERSION-HERE]** ✨).
32
+
33
+ See [build](./build) and [start](./start) for bundler-specific configuration.
34
+
35
+ :::tip
36
+ Already on webpack and want to switch? See [Migrating to Vite](https://docs.st.dev/docs/frontend/vite-migration) for a step-by-step guide.
37
+ :::
38
+
23
39
  ## Commands
24
40
 
25
41
  - [build](./build) build project for production
@@ -71,9 +87,18 @@ Use `cli.NODE_OPTIONS` or `cli.*.NODE_OPTIONS` to set or override Node options f
71
87
 
72
88
  ✨ New in **v34.1.0** ✨
73
89
 
74
- `@servicetitan/startup` provides utility functions to configure Storybook 10 or later with the same webpack and SWC settings used by the [build](./build) and [start](./start) commands.
90
+ `@servicetitan/startup` provides utility functions to configure Storybook 10 or later with the same build settings used by the [build](./build) and [start](./start) commands.
91
+
92
+ <Tabs
93
+ defaultValue="webpack"
94
+ values={[
95
+ { label: 'Webpack', value: 'webpack' },
96
+ { label: 'Vite', value: 'vite' },
97
+ ]}
98
+ >
99
+ <TabItem value="webpack">
75
100
 
76
- To use, import `webpackFinal` and `swc` from `@servicetitan/startup/storybook-config` in your Storybook `main.ts` configuration:
101
+ Import `webpackFinal` and `swc` from `@servicetitan/startup/storybook-config` in your Storybook `main.ts` configuration:
77
102
 
78
103
  ```ts title=".storybook/main.ts"
79
104
  import type { StorybookConfig } from '@storybook/react-webpack5';
@@ -92,7 +117,7 @@ const config: StorybookConfig = {
92
117
  export default config;
93
118
  ```
94
119
 
95
- ### Custom overrides
120
+ #### Custom overrides
96
121
 
97
122
  You can also pass custom webpack overrides to `webpackFinal`:
98
123
 
@@ -116,7 +141,17 @@ const config: StorybookConfig = {
116
141
  export default config;
117
142
  ```
118
143
 
119
- For details about the structure and options available in webpack overrides, see the [createWebpackConfig](./build#createwebpackconfig) section in the build documentation.
144
+ For details about the structure and options available in webpack overrides, see the [createWebpackConfig](./build/webpack#createwebpackconfig) section in the build documentation.
145
+
146
+ </TabItem>
147
+ <TabItem value="vite">
148
+
149
+ :::caution
150
+ Storybook Vite configuration is not yet supported. This is planned for a future release.
151
+ :::
152
+
153
+ </TabItem>
154
+ </Tabs>
120
155
 
121
156
  ## Cypress Component Testing Configuration
122
157
 
@@ -162,7 +197,7 @@ export default defineConfig({
162
197
  });
163
198
  ```
164
199
 
165
- For details about the structure and options available in webpack overrides, see the [createWebpackConfig](./build#createwebpackconfig) section in the build documentation.
200
+ For details about the structure and options available in webpack overrides, see the [createWebpackConfig](./build/webpack#createwebpackconfig) section in the build documentation.
166
201
 
167
202
  ### TypeScript Types
168
203
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/docs-uikit",
3
- "version": "36.0.0",
3
+ "version": "36.1.1-beta.1",
4
4
  "description": "Documentation content for Uikit packages published at docs.st.dev",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,6 +15,5 @@
15
15
  },
16
16
  "cli": {
17
17
  "webpack": false
18
- },
19
- "gitHead": "73584720991027dd55eaeb24fb8e09bad656dbad"
18
+ }
20
19
  }
@@ -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
- :::