Closed hasparus closed 4 years ago
I believe we added some webpack logging in 6.0 cc @ndelangen
The iframe isn't loading, something makes it so the iframe.html isn't generated / outputted.
I can't immediately see why.
I think some of your loaders and storybook's are conflicting, or duplicated
Yeah, I think I had conflicting loaders. This was ejected CRA, so I ended up scrapping this config and doing basically what preset-create-react-app does.
Storybook users might get problems like this due to the complexity of merging webpack configs, but I’m not sure anymore if anything can or should be done on your side.
I think we can close this issue. I don’t want to spam you 😓
Just happy that you found a solution
Sorry. I fixed my config about 15 minutes after posting the issue. I should have clarified better that my problem wasn't "Storybook fails due to wrong webpack config. How do I fix my config?", but "Storybook fails with no error message."
Something like "The iframe isn't loading. Your webpack config is probably broken." would make me very happy, but I dived into the code a bit and I have no idea how would I add it, so it feels wrong asking you to do it.
Ah I see, that's a valid bug though
Hi, sorry for disorder.
I startup now a react native project with npx react-native init appName
After it, i run npx -p @storybook/cli sb init --type react_native
but storybook keep loading, i don't have add either a new line of code.
There something i can do to fix it? Thanks in advance!
@Gongreg want to debug this together a bit?
Can we re-open this issue?
Hi @Remeic, do you run the app in the simulator or a device after run the web ui of storybook? Note that "your stories will only show up in the left-pane after your device has connected to this storybook server". You can see this note is in the welcome page of the web UI.
Hi @jasancheg , sorry for delay. Yes i run app on my device, and on device i can view default stories as CenteredView On webpage i don't see anything, only loading animation. No error in console and in terminal
After some desperate moments I think, I found the reason :)
In the docs its recommended to merge webpack configs like this: { ...config, module: { ...config.module, rules: custom.module.rules } }
The problem is: rules section in most webpack configs end with some catch-all file-loader like this: In my case that config is an ejected CRA webpack config.
{
loader: require.resolve('file-loader'),
// Exclude `js` files to keep "css" loader working as it injects
// its runtime that would otherwise be processed through "file" loader.
// Also exclude `html` and `json` extensions so they get processed
// by webpacks internal loaders.
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
options: {
name: 'static/media/[name].[hash:8].[ext]',
},
},
The config is working with the following change. Notice the |ejs in the exclude section
{
loader: require.resolve('file-loader'),
// Exclude `js` files to keep "css" loader working as it injects
// its runtime that would otherwise be processed through "file" loader.
// Also exclude `html` and `json` extensions so they get processed
// by webpacks internal loaders.
exclude: [/\.(js|mjs|jsx|ts|tsx|ejs)$/, /\.html$/, /\.json$/],
options: {
name: 'static/media/[name].[hash:8].[ext]',
},
},
Storybookjs is using a custom index.ejs template with HtmlWebpackPlugin. If you have such a loader, that will pick up the index.ejs template and copy it properly hashed to dist into your static assets folder.
Because HtmlWebpackPlugin seems to have no parameter or input checks at all, it doesn't recognize the wrong situation but just produces garbage silently. The result of the mess looks exactly like the issue @hasparus had.
Three things that could probably have helped me to debug the situation faster:
@RobIsHere This can be a fix to this issue that storybook can implement out of the box? For example i can't eject and fix
@Remeic A fix in storybook should be possible. Storybook has a separate webpack config, you can modify. You shouldn't need to eject. (Although I can only recommend it from my point of view. This way I got rid of the lock-in and I'm quite happy since)
module.exports = {
webpackFinal: (config) => {
const newCfg = {
...config,
module: {
...config.module,
rules: [
// Get rid of catch-all loader here, which is usually last
...getYourProjectsWebpackCfg().module.rules.slice(0, -1),
{ /*reinsert the modified catch all loader here, like in my issue description above */ }
]
}
};
return newCfg;
},
};
See https://storybook.js.org/docs/configurations/custom-webpack-config/
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
@RobIsHere, can you tell me where I can update this webpack config? I followed this guide but I don't have .storybook/main.js
folder. @Remeic can you tell me how you fixed it?
I ran into this error and it turns out it was because I had updated the version of @storybook/preset-create-react-app in my app. I looked through my commit history and found the original version of @storybook/preset-create-react-app installed when I ran npm sb init
. I installed that original version and it fixed the problem!
Describe the bug I'm stuck in loading/no-stories state.
To Reproduce
I was merging webpack configs incorrectly. The problem of this issue is missing logging/representation of error state. I can try to provide repro with smaller broken config.
Expected behavior Since there's no error (neither in shell nor browser console) the user can get pretty confused. A big red error pointing to what's wrong with the config would be perfect. I also looked for
--verbose
mode to see what stories are detected.Screenshots
Code snippets
My main.js (wrong, the bug is on my side)
My output of
start-storybook --debug-webpack
System:
Additional context