-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[Bug]: Storybook 8.4 cannot serve static assets declared by file #29576
Comments
Additionally I would like to add that it appears we can't configure mappings originating from |
@JReinhold Can this be related to the fs-extra removal? |
I'm pretty sure OP is correct that this is related to sirv. FWIW passing in file paths (as opposed to directory paths) has never been officially supported nor documented, I guess it just worked by chance because of the underlying implementation. These are the docs I could find on |
We're also trying to upgrade from
Only images from Do you think it's a regression? Is there any workaround/option to pass? It could be quite tedious for us to list every subfolder. Not sure if the issue from OP is related, I can also open another issue. |
Thanks @JReinhold , I did wonder if we were being a bit cheeky with the feature. 😆 For our needs I've opted to use function copyAssetsSync() {
const assets = [
{
from: '../../../public/fonts',
to: './static/public/fonts',
},
{
from: '../../../public/img/grafana_text_logo-dark.svg',
to: './static/public/img/grafana_text_logo-dark.svg',
},
{
from: '../../../public/img/grafana_text_logo-light.svg',
to: './static/public/img/grafana_text_logo-light.svg',
},
{
from: '../../../public/img/fav32.png',
to: './static/public/img/fav32.png',
},
];
const staticDir = resolve(__dirname, 'static', 'public');
emptyDirSync(staticDir);
for (const asset of assets) {
const fromPath = resolve(__dirname, asset.from);
const toPath = resolve(__dirname, asset.to);
copySync(fromPath, toPath, {
filter: (src) => !lstatSync(src).isSymbolicLink(),
});
}
} then set From my side I'd consider my original issue solved but not sure what maintainers want to do with this issue. Can either rename the title to encompass the other issues or close it? |
Similar to @jackw's problem statement, merging multiple directories into a single path was also never a feature that we supported, it just happened to work by chance. Even digging through the docs of If listing out every static dir is tedious, the workaround is very similar to the one @jackw posted above, have a pre-start script that copies all your directories into a single one, and then serve that single directory instead. The downside of this workaround is that unless you set up a file watcher like Closing this issue as won't fix. Thanks for reporting and thanks for your patience y'all. 🙏 |
Describe the bug
Storybook config accepts as staticDirs property objects of
{from: 'path', to: 'path2'}
but prior to storybook 8.4 it could also resolve directly to files. e.g.Storybook 8.4 however cannot resolve the image and attempts to render a broken html page when opening the URL directly. We specify images directly in the staticDirs config property to limit the number of assets that are uploaded to a cloud bucket at release time as uploading the entire folder was causing rate limits to kick in with our cloud provider.
Reproduction link
https://github.com/jackw/storybook-84-asset-bug
Reproduction steps
chromaui/intro-storybook-react-template
template)yarn install
yarn storybook
storybook-8.4
yarn install
yarn storybook
System
Additional context
I haven't had the chance to dig too much into it but my instinct suggests this was caused by migrating from
express
topolka
in #29230 and the use of sirv which appears to only handle directories.The text was updated successfully, but these errors were encountered: