-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mock service worker integration in storybook-build #29
Comments
Hey, @pedrohba1. Thanks for raising this. We've been working on the support of static Storybook builds for some time now, and it's already shipped in MSW. There's a remaining addon update and release to be issued, hopefully, this month, and you'll be able to use MSW with static builds just as you do during the regular dev builds. Please be patient. I'll update this issue once the new version of the addon is released. |
Actually, as I discovered that we have a wildcard version range specified for the Please update and let us know. Thanks. |
Hi @kettanaito, Thank you for the awesome library 🎉 Could you point me to some docs or post here on how to set up |
Hey, @hyogman. Thank you for the kind words! Static builds support is enabled by default since You can follow the MSW Storybook Add-on documentation to set the add-on in your Storybook project. There are no extra things necessary. Note that static support affects static Storybook builds viewed under a |
Hey @hyogman and @kettanaito. I'm encountering the same issue: the mock service provider isn't being picked up at build time. Upgrading to |
@oanaOM we are currently working on improving the Storybook add-on, which will include the exact dependency versions to ensure static build support. If updating to |
@kettanaito ohh cool, thanks for letting me know! Do you know what is the timeline for the next release? |
@kettanaito - I'm on |
@josh-biddick I'm using msw |
Hey, @josh-biddick. Could you please share the exact error you're getting during the build? At this point, the static build support should be functional, so the issues you experience may be of a different nature. I'd like to learn more. |
@kettanaito - I'm having a similar issue using the latest versions of I'm seeing the mocking behaviour perfectly functional when running the development Storybook server, but when serving a static build through The only thing I can think of that's different to the setup in the docs is that we're using the Storybook public folder instead of the regular app one, is it possible this could make a difference? The
Is there any more information I can provide for debugging purposes, or any advice on what could be incorrect in terms of configuration? Otherwise if confirmed, would it be possible to re-open this issue? |
Hey @tomcarter17 if you setup a repro repo I could take a look at it! But in terms of debugging, when providing statics via static dir in storybook, you should be able to access them via your-storybook-url.com/static-name, so try accessing your-storybook-url.com/mockServiceWorker.js and see if it resolves in the file or gives a 404 |
Thanks for the quick response @yannbf ! So I have managed to find an error now, that indicates the 404: and also going directly to |
Looks like you're not serving the worker script. Make sure:
|
Unfortunately I've done both of those things. Inside the package scripts I have so I did and I'm still receiving the above 🤔 |
A colleague pointed out an unfortunate mistake to me, in that you can see above the In any case, thanks for your responses, and for the work on this addon! |
Great to know you figured that out @tomcarter17! I'd recommend using the new notation of staticDirs which would have avoided such issue in the first place, as it's shared between dev and build in Storybook! |
Great to know, thanks for this! We're currently at 6.3 so definitely a good reason to upgrade! |
Happy to hear you've figured it out, @tomcarter17! 🎉 Yes, the |
First of all, thanks for creating this addon, It's being really useful overall. However, I have a specific use case where when building storybook with the default
build-storybook
command, which generates thestorybook-static
folder, I want to be able to get data from the mock service provider.Right now, when the build finishes, the mock service provider doesn't work (can't fetch any data).
How could I make it work within the build?
I want this behaviour because I can just send to my clients a link to check how the frontend is looking right now, which is the storybook build, and having no mocks in it will provide them nothing useful.
The text was updated successfully, but these errors were encountered: