Skip to content

Commit 4c2e2bf

Browse files
committed
Update snippets & guides related to main-config-* pages
1 parent ae6bc31 commit 4c2e2bf

17 files changed

+77
-99
lines changed

docs/configure/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ For example, if you wanted to pull both `.md` and `.js` files from the `my-proje
8585

8686
### With a configuration object
8787

88-
Additionally, you can customize your Storybook configuration to load your stories based on a configuration object. For example, if you wanted to load your stories from a `packages` directory, you could adjust your `stories` configuration field into the following:
88+
Additionally, you can customize your Storybook configuration to load your stories based on a configuration object. For example, if you wanted to load your stories from a `packages/components` directory, you could adjust your `stories` configuration field into the following:
8989

9090
<!-- prettier-ignore-start -->
9191

@@ -98,7 +98,7 @@ Additionally, you can customize your Storybook configuration to load your storie
9898

9999
<!-- prettier-ignore-end -->
100100

101-
When Storybook starts, it will look for any file containing the `stories` extension inside the `packages/stories` directory and generate the titles for your stories.
101+
When Storybook starts, it will look for any file containing the `stories` extension inside the `packages/components` directory and generate the titles for your stories.
102102

103103
### With a directory
104104

docs/configure/typescript.md

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,19 @@ Storybook provides an integrated [TypeScript](https://www.typescriptlang.org/) e
66

77
## Configure Storybook with TypeScript
88

9-
Storybook's configuration file (i.e., `main.ts`) is defined as an ESM module written in TypeScript, providing you with the baseline configuration to support your existing framework while enabling you stricter type-checking and autocompletion in your editor. Below is an abridged configuration file and additional information about the various configuration elements.
9+
Storybook's configuration file (i.e., `main.ts`) is defined as an ESM module written in TypeScript, providing you with the baseline configuration to support your existing framework while enabling you stricter type-checking and autocompletion in your editor. Below is an abridged configuration file.
1010

1111
<!-- prettier-ignore-start -->
1212

1313
<CodeSnippets
1414
paths={[
15-
'common/storybook-main-default-setup.ts.mdx',
15+
'common/storybook-main-add-ts-config.ts.mdx',
1616
]}
1717
/>
1818

19-
2019
<!-- prettier-ignore-end -->
2120

22-
| Configuration element | Description |
23-
| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
24-
| `stories` | The array of globs that indicates the [location of your story files](#configure-story-loading), relative to `main.ts` |
25-
| `staticDirs` | Sets a list of directories of [static files](./images-and-assets.md#serving-static-files-via-storybook-configuration) to be loaded by Storybook <br/> `staticDirs:['../public']` |
26-
| `addons` | Sets the list of [addons](https://storybook.js.org/addons/) loaded by Storybook <br/> `addons: ['@storybook/addon-essentials']` |
27-
| `typescript` | Configures how Storybook handles [TypeScript files](#extending-the-default-configuration) <br/> `typescript: { check: false, checkOptions: {} }` |
28-
| `framework` | Configures Storybook based on a set of [framework-specific](./frameworks.md) settings <br/> `framework: { name: '@storybook/svelte-vite', options:{} }` |
29-
| `core` | Configures Storybook's internal features.<br/> `core: { disableTelemetry: true, }` |
30-
| `docs` | Configures Storybook's [auto-generated documentation](../writing-docs/docs-page.md)<br/> `docs: { autodocs: 'tag' }` |
31-
| `features` | Enables Storybook's additional features<br/> See table below for a list of available features `features: { storyStoreV7: true }` |
32-
| `refs` | Configures [Storybook composition](../sharing/storybook-composition.md) <br/> `refs:{ example: { title: 'ExampleStorybook', url:'https://your-url.com' } }` |
33-
| `logLevel` | Configures Storybook's logs in the browser terminal. Useful for debugging <br/> `logLevel: 'debug'` |
34-
| `webpackFinal` | Customize Storybook's [Webpack](../builders/webpack.md) setup <br/> `webpackFinal: async (config:any) => { return config; }` |
35-
| `viteFinal` | Customize Storybook's Vite setup when using the [vite builder](https://github.com/storybookjs/builder-vite) <br/> `viteFinal: async (config: Vite.InlineConfig, options: Options) => { return config; }` |
36-
| `env` | Defines custom Storybook [environment variables](./environment-variables.md#using-storybook-configuration). <br/> `env: (config) => ({...config, EXAMPLE_VAR: 'Example var' }),` |
21+
See the [main configuration API reference](../api/main-config) for more details and additional properties.
3722

3823
<div class="aside">
3924

@@ -43,24 +28,7 @@ Storybook's configuration file (i.e., `main.ts`) is defined as an ESM module wri
4328

4429
### Extending the default configuration
4530

46-
Out of the box, Storybook is built to work with a wide range of third-party libraries, enabling you to safely access and document metadata (e.g., props, inputs) from your components without any additional configuration. It relies on [`babel-loader`](https://webpack.js.org/loaders/babel-loader/) for TypeScript support and optionally [`fork-ts-checker-webpack-plugin`](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/blob/v4.1.6/README.md#options) for type checking. Since Storybook supports multiple frameworks, it also includes a set of third-party packages to support each framework (e.g., `ts-loader` and `ngx-template-loader` for Angular, `react-docgen-typescript-plugin` for React). If you need to customize the default configuration for a specific use case scenario, you can extend the default configuration to suit your needs. Listed below are some examples and a table with the available options.
47-
48-
<!-- prettier-ignore-start -->
49-
50-
<CodeSnippets
51-
paths={[
52-
'common/storybook-main-add-ts-config.ts.mdx',
53-
]}
54-
/>
55-
56-
<!-- prettier-ignore-end -->
57-
58-
| Field | Framework | Description | Type |
59-
| :------------------------------- | :-------- | :------------------------------------------------------------------------------------------ | :---------------------------------------------------------------------------------------------------------------- |
60-
| **check** | All | Optionally run fork-ts-checker-webpack-plugin | boolean |
61-
| **checkOptions** | All | Options to pass to fork-ts-checker-webpack-plugin if it's enabled | <a href="https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/blob/v4.1.6/README.md#options">See Docs</a> |
62-
| **reactDocgen** | React | Which react docgen processor to run: `"react-docgen-typescript"`, `"react-docgen"`, `false` | string or false |
63-
| **reactDocgenTypescriptOptions** | React | Options to pass to react-docgen-typescript-plugin if react-docgen-typescript is enabled. | [See docs](https://github.com/hipstersmoothie/react-docgen-typescript-plugin) |
31+
Out of the box, Storybook is built to work with a wide range of third-party libraries, enabling you to safely access and document metadata (e.g., props, inputs) from your components without any additional configuration. It relies on [`babel-loader`](https://webpack.js.org/loaders/babel-loader/) for TypeScript support and optionally [`fork-ts-checker-webpack-plugin`](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/blob/v4.1.6/README.md#options) for type checking. Since Storybook supports multiple frameworks, it also includes a set of third-party packages to support each framework (e.g., `ts-loader` and `ngx-template-loader` for Angular, `react-docgen-typescript-plugin` for React). If you need to customize the default configuration for a specific use case scenario, refer to the [`config.typescript` API reference](../api/main-config-typescript.md).
6432

6533
The above example extends the baseline configuration to remove existing props from third-party libraries. Useful if you want to document only your components. However, if you need to include them, you can do so by adjusting your configuration as follows:
6634

docs/snippets/common/storybook-main-add-sass-config.js.mdx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,13 @@
33

44
import * as path from 'path';
55

6-
// Export a function. Accept the base config as the only param.
76
export default {
7+
framework: '@storybook/vue3-vite',
88
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
9-
addons: [
10-
'@storybook/addon-links',
11-
'@storybook/addon-essentials',
12-
'@storybook/addon-interactions',
13-
],
149
webpackFinal: async (config, { configType }) => {
1510
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
1611
// You can change the configuration based on that.
17-
// 'PRODUCTION' is used when building the static version of storybook.
12+
// 'PRODUCTION' is used when building the static version of Storybook.
1813

1914
// Make whatever fine-grained changes you need
2015
config.module.rules.push({

docs/snippets/common/storybook-main-add-sass-config.ts.mdx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,11 @@
44
// Replace your-framework with the framework you are using (e.g., react-webpack5, vue3-webpack5)
55
import type { StorybookConfig } from '@storybook/your-framework';
66

7-
// your app's webpack.config.js
8-
import custom from '../webpack.config.js';
9-
107
const config: StorybookConfig = {
11-
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
12-
addons: [
13-
'@storybook/addon-links',
14-
'@storybook/addon-essentials',
15-
'@storybook/addon-interactions',
16-
],
178
webpackFinal: async (config, { configType }) => {
189
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
1910
// You can change the configuration based on that.
20-
// 'PRODUCTION' is used when building the static version of storybook.
11+
// 'PRODUCTION' is used when building the static version of Storybook.
2112

2213
// Make whatever fine-grained changes you need
2314
config.module.rules.push({

docs/snippets/common/storybook-main-add-ts-config.ts.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import type { StorybookConfig } from '@storybook/your-framework';
66

77
const config: StorybookConfig = {
8-
stories: [],
9-
addons: [],
8+
framework: '@storybook/vue3-vite',
9+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
1010
typescript: {
1111
check: false,
1212
checkOptions: {},

docs/snippets/common/storybook-main-env-field-config.js.mdx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
// .storybook/main.js
33

44
export default {
5+
framework: '@storybook/vue3-vite',
56
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
6-
addons: [
7-
'@storybook/addon-links',
8-
'@storybook/addon-essentials',
9-
'@storybook/addon-interactions',
10-
],
117
/*
128
* 👇 The `config` argument contains all the other existing environment variables.
139
* Either configured in an `.env` file or configured on the command line.

docs/snippets/common/storybook-main-env-field-config.ts.mdx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@
55
import type { StorybookConfig } from '@storybook/your-framework';
66

77
const config: StorybookConfig = {
8+
framework: '@storybook/vue3-vite',
89
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
9-
addons: [
10-
'@storybook/addon-links',
11-
'@storybook/addon-essentials',
12-
'@storybook/addon-interactions',
13-
],
1410
/*
1511
* 👇 The `config` argument contains all the other existing environment variables.
1612
* Either configured in an `.env` file or configured on the command line.

docs/snippets/common/storybook-main-ref-remote.js.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
// .storybook/main.js
33

44
export default {
5-
// Your Storybook configuration
5+
framework: '@storybook/vue3-vite',
6+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
67
refs: {
78
'design-system': {
89
title: 'Storybook Design System',
9-
url: 'https://5ccbc373887ca40020446347-yldsqjoxzb.chromatic.com',
10+
url: 'https://master--5ccbc373887ca40020446347.chromatic.com/',
1011
expanded: false, // Optional, true by default
1112
},
1213
},

docs/snippets/common/storybook-main-ref-remote.ts.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
import type { StorybookConfig } from '@storybook/your-framework';
66

77
const config: StorybookConfig = {
8-
// Your Storybook configuration
8+
framework: '@storybook/vue3-vite',
9+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
910
refs: {
1011
'design-system': {
1112
title: 'Storybook Design System',
12-
url: 'https://5ccbc373887ca40020446347-yldsqjoxzb.chromatic.com',
13+
url: 'https://master--5ccbc373887ca40020446347.chromatic.com/',
1314
expanded: false, // Optional, true by default
1415
},
1516
},

docs/snippets/common/storybook-main-with-multiple-static-dir.js.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// .storybook/main.js
33

44
export default {
5-
stories: [],
6-
addons: [],
5+
framework: '@storybook/vue3-vite',
6+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
77
staticDirs: ['../public', '../static'],
88
};
99
```

0 commit comments

Comments
 (0)