storybook: Unable to host static build on sub folder
I’m trying to host the static build of story book on a sub folder e.g. https://domain.com/shared-ui and I’m having some trouble. The index.html file generated by storybook has all of the scripts like this <script src="main.[hash].bundle.js"> which is an issue because they’re not at main.[hash].bundle.js they’re at /shared-ui/main.[hash].bundle.js I’ve tried all the config options and it’s still not prepending shared-ui to those files.
Things I’ve tried:
- Changing values in the
.storybook/wepback.config.js-config.output.path,config.output.filename&config.output.publicPath - Changing the
homepagevalue inpackage.json - Running the
build-storybookcommand with-o /shared-ui/to output the static site to/shared-ui/ - Modifying the webpack config HtmlWebpackPlugin options to use a custom template for the page generation - this seems this only works for
iframe.html(also built by the static site script) and notindex.html
Ideally I’m looking for a way to configure sb correctly to generate the script tags in index.html with the correct url or override the template for index.html so I can do it myself
Many thanks for any help that you can give
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 19 (3 by maintainers)
@marr If the web server doesn’t enforce the trailing slash add a redirect to
manager-head.html:This will also work for local dev, since the condition won’t be triggered.
try it
and run
build-storybook.If you want to inject the
baserule only for the production (static) builds, and leave the dev server untouched, you have to:.storybook/manager-head.htmlfilemanagerHeadpreset in yourmain.jsfile and inject thebasethere, checking forconfTypecondition, like this:Ref: #13432
Having this same issue, anyway to resolve this?
The
basesolution seems to work fine for production (static) builds. But how do you get the dev server working with it?Just wanted to chime in and say I too had this issue, but it was because I had a configuration error in
webpack.config.jsunrelated to this. I was able to get this working out-of-the-box with the latest Storybook with no configurations 🎉.If others are experiencing the same problem, it may be from some custom configuration you or someone on your team added. Try removing all of that, then adding your config back one-by-one to see what’s breaking the subfolder build.