storybook/docs/api/main-config/main-config-core.mdx
Charles de Dreuille 2d32ceaba6 API Main config
2024-06-17 18:56:10 +01:00

174 lines
3.9 KiB
Plaintext

---
title: 'core'
sidebar:
order: 8
title: core
---
Parent: [main.js|ts configuration](./main-config.mdx)
Type:
```ts
{
builder?: string | { name: string; options?: BuilderOptions };
channelOptions?: ChannelOptions;
crossOriginIsolated?: boolean;
disableProjectJson?: boolean;
disableTelemetry?: boolean;
disableWebpackDefaults?: boolean;
disableWhatsNewNotifications?: boolean;
enableCrashReports?: boolean;
renderer?: RendererName;
}
```
Configures Storybook's internal features.
## `builder`
Type:
```ts
| '@storybook/builder-vite' | '@storybook/builder-webpack5'
| {
name: '@storybook/builder-vite' | '@storybook/builder-webpack5';
options?: BuilderOptions;
}
```
Configures Storybook's builder, [Vite](../../builders/vite.mdx) or [Webpack](../../builders/webpack.mdx).
<Callout variant="info" icon="💡">
With the new [Framework API](../new-frameworks.mdx), [`framework.options.builder`](./main-config-framework.mdx#optionsbuilder) is now the preferred way to configure the builder.
You should only use `core.builder.options` if you need to configure a builder that is not part of a framework.
</Callout>
{/* prettier-ignore-start */}
<CodeSnippets path="main-config-core-builder.md" />
{/* prettier-ignore-end */}
## `channelOptions`
Type: `ChannelOptions`
```ts
{
allowClass: boolean;
allowDate: boolean;
allowFunction: boolean;
allowRegExp: boolean;
allowSymbol: boolean;
allowUndefined: boolean;
lazyEval: boolean;
maxDepth: number;
space: number | undefined;
}
```
Configures the channel used by Storybook to communicate between the manager and preview.
Only two properties are likely to be used:
### `channelOptions.allowFunction`
Type: `boolean`
Default: `false`
Enables serializing functions across the channel, which can be a security risk.
### `channelOptions.maxDepth`
Type: `number`
Default: `3`
The maximum depth of nested objects to serialize across the channel. Larger values will be slower.
## `crossOriginIsolated`
Type: `boolean`
Enable CORS headings to run document in a "secure context". See [SharedArrayBuffer security requirements](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements)
This enables these headers in development-mode:
* `Cross-Origin-Opener-Policy: same-origin`
* `Cross-Origin-Embedder-Policy: require-corp`
{/* prettier-ignore-start */}
<CodeSnippets path="main-config-core-cross-origin-isolated.md" />
{/* prettier-ignore-end */}
## `disableProjectJson`
Type: `boolean`
Disables the generation of `project.json`, a file containing Storybook metadata
{/* prettier-ignore-start */}
<CodeSnippets path="main-config-core-disable-project-json.md" />
{/* prettier-ignore-end */}
## `disableTelemetry`
Type: `boolean`
Disables Storybook's [telemetry collection](../../configure/telemetry.mdx).
{/* prettier-ignore-start */}
<CodeSnippets path="main-config-core-disable-telemetry.md" />
{/* prettier-ignore-end */}
## `disableWebpackDefaults`
Type: `boolean`
Disables Storybook's default Webpack configuration.
{/* prettier-ignore-start */}
<CodeSnippets path="main-config-core-disable-webpack-defaults.md" />
{/* prettier-ignore-end */}
## `disableWhatsNewNotifications`
Type: `boolean`
Disables the "What's New" notifications in the UI for new Storybook versions and ecosystem updates (e.g., [addons](https://storybook.js.org/integrations/), [content](https://storybook.js.org/blog/), etc.).
{/* prettier-ignore-start */}
<CodeSnippets path="main-config-core-disable-update-notifications.md" />
{/* prettier-ignore-end */}
## `enableCrashReports`
Type: `boolean`
Enable crash reports to be sent to Storybook [telemetry](../../configure/telemetry.mdx).
{/* prettier-ignore-start */}
<CodeSnippets path="main-config-core-enable-crash-reports.md" />
{/* prettier-ignore-end */}
## `renderer`
Type: `RendererName`
{/* TODO: Is this used? Should it be documented? */}