You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Register the route for Storybook in your symfony project:
82
+
83
+
```yaml
84
+
# config/routes/storybook.yaml
85
+
86
+
storybook:
87
+
resource: '@StorybookBundle/config/routes.php'
88
+
```
89
+
61
90
Run Storybook with:
62
91
```shell
63
-
yarn run storybook
92
+
yarn run sb dev -p 6006
93
+
```
94
+
95
+
Additionally, you can add custom scripts to your `package.json` file:
96
+
97
+
```json
98
+
{
99
+
"scripts": {
100
+
"storybook": "sb dev -p 6006",
101
+
"build-storybook": "sb build"
102
+
}
103
+
}
64
104
```
65
105
66
106
## Symfony configuration
@@ -69,17 +109,17 @@ yarn run storybook
69
109
70
110
As the Symfony integration relies on the Storybook's server renderer, it makes requests to your Symfony server to render Twig components. These requests are cross origins, so you have to configure Symfony to accept them from your Storybook instance.
71
111
72
-
There is two options to achieve this. You can either configure the Storybook host in the bundle, or use the popular NelmioCORS bundle.
112
+
There is two options to achieve this. You can either configure the Storybook host in the bundle, or use the popular [NelmioCorsBundle](https://symfony.com/bundles/NelmioCorsBundle/current/index.html).
73
113
74
-
In the bundle:
114
+
In the StorybookBundle:
75
115
76
116
```yaml
77
117
# config/storybook.yaml
78
118
storybook:
79
119
server: http://localhost:6006
80
120
```
81
121
82
-
With NelmioCORS:
122
+
With NelmioCorsBundle:
83
123
```yaml
84
124
# config/storybook.yaml
85
125
storybook:
@@ -160,6 +200,40 @@ export const Secondary = {
160
200
template: Button, // You can pass a specific template for a story
161
201
};
162
202
203
+
```
204
+
# Troubleshooting
205
+
206
+
## Conflicting `string-width` module
207
+
208
+
When you install storybook, you might encounter the following warnings:
209
+
210
+
```
211
+
warning Pattern ["string-width-cjs@npm:string-width@^4.2.0"] is trying to unpack in the same destination "/home/john/.cache/yarn/v6/npm-string-width-cjs-4.2.3-269c7117d27b05ad2e536830a8ec895ef9c6d010-integrity/node_modules/string-width-cjs" as pattern ["string-width@^4.2.0"]. This could result in non-deterministic behavior, skipping.
212
+
warning Pattern ["strip-ansi-cjs@npm:strip-ansi@^6.0.1"] is trying to unpack in the same destination "/home/john/.cache/yarn/v6/npm-strip-ansi-cjs-6.0.1-9e26c63d30f53443e9489495b2105d37b67a85d9-integrity/node_modules/strip-ansi-cjs" as pattern ["strip-ansi@^6.0.0"]. This could result in non-deterministic behavior, skipping.
213
+
warning Pattern ["string-width@^4.1.0"] is trying to unpack in the same destination "/home/john/.cache/yarn/v6/npm-string-width-cjs-4.2.3-269c7117d27b05ad2e536830a8ec895ef9c6d010-integrity/node_modules/string-width-cjs" as pattern ["string-width@^4.2.0"]. This could result in non-deterministic behavior, skipping.
214
+
```
215
+
216
+
217
+
When trying to run storybook, if you get the following error:
218
+
```
219
+
🔴 Error: It looks like you are having a known issue with package hoisting.
220
+
Please check the following issue for details and solutions: https://github.com/storybookjs/storybook/issues/22431#issuecomment-1630086092
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/john/Projects/storybook/node_modules/string-width/index.js from /home/john/Projects/storybook/node_modules/cli-table3/src/utils.js not supported.
228
+
229
+
```
230
+
231
+
Then you have to clean the yarn cache for the conflicting module and reinstall:
0 commit comments