@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.
@@ -0,0 +1,109 @@
1
+ ---
2
+ title: Vite
3
+ ---
4
+
5
+ ✨ New in **v37.0.0** ✨
6
+
7
+ Vite is an alternative dev server for `startup start`, enabled with `--bundler=vite`.
8
+
9
+ ```sh
10
+ npx startup start --bundler=vite
11
+ ```
12
+
13
+ To make Vite the default, set `cli.bundler` in the project's root `package.json`:
14
+
15
+ ```json title="package.json"
16
+ {
17
+ "cli": {
18
+ "bundler": "vite"
19
+ }
20
+ }
21
+ ```
22
+
23
+ The `--bundler` flag overrides it per invocation.
24
+
25
+ :::tip
26
+ For build-time configuration (minification, plugin overrides, custom templates), see [Vite build](../build/vite).
27
+ :::
28
+
29
+ ## Server Options
30
+
31
+ ### Port {#port}
32
+
33
+ Use `cli.vite.port` to select the port for the dev server. Default: 8080 for applications, 8888 for MFEs.
34
+
35
+ ```json title="package.json"
36
+ {
37
+ "cli": {
38
+ "vite": {
39
+ "port": 3000
40
+ }
41
+ }
42
+ }
43
+ ```
44
+
45
+ ### Proxy
46
+
47
+ Configure a dev server proxy in `vite.dev.config.ts`:
48
+
49
+ ```ts title="vite.dev.config.ts"
50
+ import { defineConfig } from '@servicetitan/startup/vite';
51
+
52
+ export default defineConfig({
53
+ config: {
54
+ server: {
55
+ proxy: {
56
+ '/api': {
57
+ target: 'http://localhost:3000',
58
+ changeOrigin: true,
59
+ },
60
+ },
61
+ },
62
+ },
63
+ });
64
+ ```
65
+
66
+ For advanced use cases like request interception, use the `configure` callback:
67
+
68
+ ```ts title="vite.dev.config.ts"
69
+ import { defineConfig } from '@servicetitan/startup/vite';
70
+
71
+ export default defineConfig({
72
+ config: {
73
+ server: {
74
+ proxy: {
75
+ '/api': {
76
+ target: 'http://localhost:3000',
77
+ configure: proxy => {
78
+ proxy.on('proxyReq', (proxyReq, req) => {
79
+ proxyReq.setHeader('X-Custom-Header', 'value');
80
+ });
81
+ },
82
+ },
83
+ },
84
+ },
85
+ },
86
+ });
87
+ ```
88
+
89
+ See [Vite server.proxy](https://vite.dev/config/server-options#server-proxy) for the full list of options.
90
+
91
+ ### Disabling the dev server
92
+
93
+ Set `cli.vite.devServer` to `false` to run `startup start` without an HTTP dev server. Vite instead builds in watch mode, recompiling to the output directory on every change, so a separate server can serve the files from disk.
94
+
95
+ ```json title="package.json"
96
+ {
97
+ "cli": {
98
+ "vite": {
99
+ "devServer": false
100
+ }
101
+ }
102
+ }
103
+ ```
104
+
105
+ ## Hot Module Replacement
106
+
107
+ Vite provides fast HMR out of the box. CSS changes are applied instantly without a full page reload.
108
+
109
+ For MFEs running in shadow DOM, CSS HMR uses `adoptedStyleSheets`. Style updates are applied to the shadow root automatically without affecting the host page.
@@ -0,0 +1,49 @@
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
+ ### Disabling the dev server
38
+
39
+ Set `cli.webpack.devServer` to `false` to run `startup start` without an HTTP dev server. Webpack instead builds in watch mode, recompiling to the output directory on every change, so a separate server can serve the files from disk.
40
+
41
+ ```json title="package.json"
42
+ {
43
+ "cli": {
44
+ "webpack": {
45
+ "devServer": false
46
+ }
47
+ }
48
+ }
49
+ ```
@@ -20,6 +20,19 @@ It's overwhelming how many development dependencies are required to work with th
20
20
 
21
21
  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
22
 
23
+ ## Bundlers
24
+
25
+ `startup` supports two bundlers:
26
+
27
+ - **Webpack**: the default bundler.
28
+ - **Vite** (✨ New in **v37.0.0** ✨): opt-in via `--bundler=vite` or `cli.bundler` in project's root `package.json`.
29
+
30
+ See [build](./build) and [start](./start) for bundler-specific configuration.
31
+
32
+ :::tip
33
+ 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.
34
+ :::
35
+
23
36
  ## Commands
24
37
 
25
38
  - [build](./build) build project for production
@@ -71,9 +84,11 @@ Use `cli.NODE_OPTIONS` or `cli.*.NODE_OPTIONS` to set or override Node options f
71
84
 
72
85
  ✨ New in **v34.1.0** ✨
73
86
 
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.
87
+ `@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.
75
88
 
76
- To use, import `webpackFinal` and `swc` from `@servicetitan/startup/storybook-config` in your Storybook `main.ts` configuration:
89
+ ### Webpack
90
+
91
+ Import `webpackFinal` and `swc` from `@servicetitan/startup/storybook-config` in your Storybook `main.ts` configuration:
77
92
 
78
93
  ```ts title=".storybook/main.ts"
79
94
  import type { StorybookConfig } from '@storybook/react-webpack5';
@@ -92,7 +107,7 @@ const config: StorybookConfig = {
92
107
  export default config;
93
108
  ```
94
109
 
95
- ### Custom overrides
110
+ #### Custom overrides
96
111
 
97
112
  You can also pass custom webpack overrides to `webpackFinal`:
98
113
 
@@ -116,15 +131,66 @@ const config: StorybookConfig = {
116
131
  export default config;
117
132
  ```
118
133
 
119
- For details about the structure and options available in webpack overrides, see the [createWebpackConfig](./build#createwebpackconfig) section in the build documentation.
134
+ For details about the structure and options available in webpack overrides, see the [createWebpackConfig](./build/webpack#createwebpackconfig) section in the build documentation.
135
+
136
+ ### Vite
137
+
138
+ ✨ New in **v37.0.0** ✨
139
+
140
+ Import `viteFinal` from `@servicetitan/startup/storybook-config` in your Storybook `main.ts` configuration:
141
+
142
+ ```ts title=".storybook/main.ts"
143
+ import type { StorybookConfig } from '@storybook/react-vite';
144
+ import { createRequire } from 'node:module';
145
+
146
+ const require = createRequire(import.meta.url);
147
+ const { viteFinal } = require('@servicetitan/startup/storybook-config');
148
+
149
+ const config: StorybookConfig = {
150
+ framework: '@storybook/react-vite',
151
+ stories: ['../**/*.stories.ts?(x)'],
152
+ viteFinal,
153
+ };
154
+
155
+ export default config;
156
+ ```
157
+
158
+ `viteFinal` applies startup's CSS modules, Less, and SVG configuration to Storybook's resolved Vite config so stories render the same way as your production build. It also pre-bundles and dedupes React so the preview loads a single React instance in a monorepo.
159
+
160
+ #### Custom configuration
161
+
162
+ To add your own Vite options, wrap `viteFinal` and merge the result:
163
+
164
+ ```ts title=".storybook/main.ts"
165
+ import type { StorybookConfig } from '@storybook/react-vite';
166
+ import { createRequire } from 'node:module';
167
+ import { mergeConfig } from 'vite';
168
+
169
+ const require = createRequire(import.meta.url);
170
+ const { viteFinal } = require('@servicetitan/startup/storybook-config');
171
+
172
+ const config: StorybookConfig = {
173
+ framework: '@storybook/react-vite',
174
+ stories: ['../src/**/*.stories.ts?(x)'],
175
+ viteFinal: (config, options) =>
176
+ mergeConfig(viteFinal(config, options), {
177
+ /* Custom Vite config */
178
+ }),
179
+ };
180
+
181
+ export default config;
182
+ ```
120
183
 
121
184
  ## Cypress Component Testing Configuration
122
185
 
123
- ✨ New in **v35.1.0** ✨
186
+ `@servicetitan/startup` provides utility functions to configure Cypress for component testing with the same settings used by the [build](./build) and [start](./start) commands.
187
+ This ensures your Cypress component tests run with the same transpilation and module resolution rules as your application code.
124
188
 
125
- `@servicetitan/startup` provides a `webpackConfig` utility function to configure Cypress for component testing with the same webpack and SWC settings used by the [build](./build) and [start](./start) commands. This ensures your Cypress component tests run with the same transpilation and module resolution rules as your application code.
189
+ ### Webpack
126
190
 
127
- To use the configuration, import `webpackConfig` from `@servicetitan/startup/cypress-config` in your Cypress configuration:
191
+ ✨ New in **v35.1.0** ✨
192
+
193
+ Import `webpackConfig` from `@servicetitan/startup/cypress-config` in your Cypress configuration:
128
194
 
129
195
  ```ts title="cypress.config.ts"
130
196
  import { defineConfig } from 'cypress';
@@ -141,8 +207,6 @@ export default defineConfig({
141
207
  });
142
208
  ```
143
209
 
144
- ### Custom overrides
145
-
146
210
  You can also pass custom webpack overrides to `webpackConfig`:
147
211
 
148
212
  ```ts title="cypress.config.ts"
@@ -162,7 +226,47 @@ export default defineConfig({
162
226
  });
163
227
  ```
164
228
 
165
- For details about the structure and options available in webpack overrides, see the [createWebpackConfig](./build#createwebpackconfig) section in the build documentation.
229
+ For details about the structure and options available in webpack overrides, see [createWebpackConfig](./build/webpack#createwebpackconfig).
230
+
231
+ ### Vite
232
+
233
+ ✨ New in **v37.0.0** ✨
234
+
235
+ For projects building with Vite, import `viteConfig` from `@servicetitan/startup/cypress-config` and set `bundler: 'vite'`.
236
+
237
+ ```ts title="cypress.config.ts"
238
+ import { defineConfig } from 'cypress';
239
+ import { viteConfig } from '@servicetitan/startup/cypress-config';
240
+
241
+ export default defineConfig({
242
+ component: {
243
+ devServer: {
244
+ framework: 'react',
245
+ bundler: 'vite',
246
+ viteConfig,
247
+ },
248
+ },
249
+ });
250
+ ```
251
+
252
+ Pass an optional Vite `InlineConfig` to merge custom options:
253
+
254
+ ```ts title="cypress.config.ts"
255
+ import { defineConfig } from 'cypress';
256
+ import { viteConfig } from '@servicetitan/startup/cypress-config';
257
+
258
+ export default defineConfig({
259
+ component: {
260
+ devServer: {
261
+ framework: 'react',
262
+ bundler: 'vite',
263
+ viteConfig: viteConfig({
264
+ /* Vite InlineConfig overrides */
265
+ }),
266
+ },
267
+ },
268
+ });
269
+ ```
166
270
 
167
271
  ### TypeScript Types
168
272
 
@@ -2,11 +2,11 @@
2
2
  title: Jest
3
3
  ---
4
4
 
5
- `Startup test` uses the Jest by default, with a built-in configuration optimized for ServiceTitan workspaces.
5
+ `Startup test` uses the Jest by default, with a built-in configuration optimized for ServiceTitan projects.
6
6
 
7
7
  ## Configuration
8
8
 
9
- You can override the defaults by specifying [Jest options](https://jestjs.io/docs/configuration) in your workspace `package.json` under the `"cli.jest"` key (the `"cli.test"` key also works, for backward compatibility). For example,
9
+ You can override the defaults by specifying [Jest options](https://jestjs.io/docs/configuration) in your project's root `package.json` under the `"cli.jest"` key (the `"cli.test"` key also works, for backward compatibility). For example,
10
10
 
11
11
  ```json title="package.json"
12
12
  {
@@ -24,7 +24,7 @@ You can also use a standard Jest config file (such as `jest.config.js`) or pass
24
24
 
25
25
  ### Package.json
26
26
 
27
- Use the workspace `package.json` to set up code that runs before each test file is executed:
27
+ Use the project's root `package.json` to set up code that runs before each test file is executed:
28
28
 
29
29
  ```json title="package.json"
30
30
  {
@@ -51,7 +51,7 @@ module.exports = {
51
51
  ```
52
52
 
53
53
  :::caution
54
- If your project includes a standard Jest config file and also specifies Jest options in the workspace `package.json`, ensure that the configurations are mutually exclusive.
54
+ If your project includes a standard Jest config file and also specifies Jest options in the project's root `package.json`, ensure that the configurations are mutually exclusive.
55
55
  To avoid confusing or unexpected behavior, do not specify the same setting in both locations.
56
56
  :::
57
57
 
@@ -5,7 +5,7 @@ title: test
5
5
  Runs your project's tests.
6
6
 
7
7
  - Supports both Jest and Vitest.
8
- - Automatically selects the test runner based on your workspace configuration or the `--runner` option.
8
+ - Automatically selects the test runner based on your project's configuration or the `--runner` option.
9
9
  - Handles runner-specific arguments and passes them through to the underlying test tool.
10
10
 
11
11
  ## Usage
@@ -4,7 +4,7 @@ title: Vitest
4
4
 
5
5
  ✨ New in **v31.6.0** ✨
6
6
 
7
- You can change the default test runner from `jest` to `vitest` in your workspace's `package.json`:
7
+ You can change the default test runner from `jest` to `vitest` in the project's root `package.json`:
8
8
 
9
9
  ```json title="package.json"
10
10
  {
@@ -21,18 +21,18 @@ Or, you can override it per invocation with the `--runner` option.
21
21
  The Vitest runner uses a layered configuration approach to provide sensible defaults while allowing full customization.
22
22
 
23
23
  - Uses the default, built-in configuration as a base.
24
- - Merges workspace settings from `package.json`.
24
+ - Merges project's settings from the root `package.json`.
25
25
  - Merges settings from your Vitest config file.
26
26
  - Merges command line options last.
27
27
 
28
28
  1. **Default Configuration:**
29
- The runner starts with a built-in default configuration optimized for ServiceTitan workspaces. This includes sensible coverage settings, the environment (`jsdom`), file exclusions, and more.
29
+ The runner starts with a built-in default configuration optimized for ServiceTitan projects. This includes sensible coverage settings, the environment (`jsdom`), file exclusions, and more.
30
30
 
31
31
  2. **Workspace Configuration:**
32
- You can customize the configuration by specifying [Vitest options](https://vitest.dev/config) in your workspace `package.json` under the `"cli.vitest"` key.
32
+ You can customize the configuration by specifying [Vitest options](https://vitest.dev/config) in your project's root `package.json` under the `"cli.vitest"` key.
33
33
 
34
34
  3. **Vitest Config File:**
35
- If your project includes a standard Vitest config file (such as `vitest.config.ts` or `vite.config.ts`), its settings will merged with the defaults and workspace configuration.
35
+ If your project includes a standard Vitest config file (such as `vitest.config.ts` or `vite.config.ts`), its settings will be merged with the defaults and project's configuration.
36
36
 
37
37
  4. **Command Line Arguments:**
38
38
  Any options passed directly via the command line (e.g., `npx startup test --runner vitest --coverage`) take highest precedence over previous configuration layers.
@@ -41,7 +41,7 @@ The Vitest runner uses a layered configuration approach to provide sensible defa
41
41
 
42
42
  ### Package.json
43
43
 
44
- Use workspace `package.json` to make `vitest` APIs available [globally](https://vitest.dev/config/#globals) like Jest:
44
+ Use project's root `package.json` to make `vitest` APIs available [globally](https://vitest.dev/config/#globals) like Jest:
45
45
 
46
46
  ```json title="package.json"
47
47
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@servicetitan/docs-uikit",
3
- "version": "36.3.1",
3
+ "version": "37.0.0",
4
4
  "description": "Documentation content for Uikit packages published at docs.st.dev",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,5 +16,5 @@
16
16
  "cli": {
17
17
  "webpack": false
18
18
  },
19
- "gitHead": "93a049ba1e5cb737afb7bc95c06020736bc61a38"
19
+ "gitHead": "f0acf332ece207c91acb18da23a614efbc8551ec"
20
20
  }