@servicetitan/docs-uikit 36.3.1 → 36.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/BREAKING_CHANGES.mdx +1 -1
- package/docs/ai-marketplace.mdx +5 -4
- package/docs/datadog-rum.mdx +302 -40
- package/docs/install.mdx +10 -6
- package/docs/lazy-module.mdx +1 -1
- package/docs/microfrontends/hosting.mdx +6 -4
- package/docs/microfrontends/sharing-dependencies.mdx +15 -17
- package/docs/startup/build/build.mdx +199 -0
- package/docs/startup/build/vite.mdx +274 -0
- package/docs/startup/build/webpack.mdx +117 -0
- package/docs/startup/start/start.mdx +48 -0
- package/docs/startup/start/vite.mdx +90 -0
- package/docs/startup/start/webpack.mdx +39 -0
- package/docs/startup/startup.mdx +40 -5
- package/package.json +2 -2
- package/docs/startup/build.mdx +0 -310
- package/docs/startup/start.mdx +0 -73
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Vite
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
✨ New in **36.4.0** ✨
|
|
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
|
+
:::
|
package/docs/startup/startup.mdx
CHANGED
|
@@ -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 **36.4.0** ✨).
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "36.4.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": "
|
|
19
|
+
"gitHead": "8beab9ae3a70ce381e8cd53f2de8691640e96c6e"
|
|
20
20
|
}
|
package/docs/startup/build.mdx
DELETED
|
@@ -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
|
-
```
|
package/docs/startup/start.mdx
DELETED
|
@@ -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
|
-
:::
|