-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Windows staticDirs issue - Storybook not loading assets despite path seemingly correct #17271
Comments
@kroeder can you please look into this? i think you're doing this successfully on your project |
any updates? its pretty annoying to have to manually import all my assets from static. |
I just ran into this recently, |
Hi, I've just tried this with staticDir instead of staticDirs and it doesn't output the assets at all that way so I suspect it's something else that's not right. |
It might sound dumb, but for me, I just realized I am using version 6.2, and 6.2 doesn't have |
thats fair, Im using 6.4 which has OP's issue though |
Hi @kroeder, just wondering if there's any update on this, is it looking like an incorrect config on my side or is something not right with Storybook? Keen not to have to revert back to an older version. Thanks |
the same for me. At first i tried the simple config:
but this means all dir will flatten. cheers
|
Can confirm, broken on windows, works on WSL Ubuntu. my config: Same problem as OP, as you can see, the path duplicated the |
the colon is a seperator for "src":"destination" ;) i promise the backslashes are the main problem. cheers |
Are you sure about that ? |
👆🏼 So I fixed this and submitted a PR, details are (copied from PR): Noticed that the test "supports absolute file paths with custom endpoint" didn't cover the reality for Windows. The Digging in, the regex split in To work around this, I changed the code to look for the last colon
Once this was determined, the final piece of the puzzle was ensuring the |
Whoopee!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.5.0-alpha.47 containing PR #17641 that references this issue. Upgrade today to the
|
Sorry to jump in a closed issue, but is this problem also linked to the fact that I am not able to use the following ?
Based on a docs configuration object example found here, it should work with a leading foward slash. |
Would be nice to backport this to 6.4.x if it's not too much trouble 😄 |
I got stuck because of this bug and I can't upgrade to another version... You can also configure a directory (or a list of directories) for searching static content when you are starting Storybook. You can do that with the -s flag. Thanks for your great work and all the best for the Storybook team! |
Still doesn't work |
Did anyone get this to work? I have a folder in the root called public with a svg folder inside. The svg folder ends up in the root of storybook-static. I need it to put the svg folder inside a folder called public. |
I also on 6.5.17 Did add this in main.js but it does nothing.
|
Yep - experiencing this issue as well with 6.5.14. // preview.js
import Theme from "../src/components/Theme/Theme";
import { ColorConfig } from "@company/company-ui";
import "../assets/fonts.css"; // 👈 fonts are in here
import "../assets/global.css";
import "../assets/test.css";
export const decorators = [
(Story) => (
<Theme>
<ColorConfig mainColor="rgb(91, 121, 139)" />
<Story />
</Theme>
),
];
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}; // main.js
module.exports = {
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
],
framework: "@storybook/react",
"core": {
"builder": "@storybook/builder-webpack5"
},
staticDirs: ["../assets"],
};
It should be loading a Roboto font, but it doesn't load, so the browser is falling back to Times New Roman. Further inspection reveals that my MVCE |
I confirm that this is still an issue in 6.5.16. :( |
The same issue in 6.5.13 |
Update: |
Ran into this. It seems that having '..' in the path breaks somewhere in the path normalization chain. I had |
I'm running into this as well with version 8.2.6 of storybook, but I can't reorganize the files like SeanMcMillan suggests, as it's tied to a nextjs project that requires the current folder structure. My problem is that they handle the public folder differently. In nextjs, files in the public directory are treated as if they are in the root of the project, so a font would be loaded with @font-face {
font-family: "ExampleFont";
src: url("/fonts/ExampleFont.otf") format("opentype")
} To get it to load in storybook, I have to include "/public" in the url, even though I've set up a static directory to map the "../public/fonts" to "/fonts" @font-face {
font-family: "ExampleFont";
src: url("/public/fonts/ExampleFont.otf") format("opentype")
} The strange thing is that the path without "public" does work when I visit the site on the front end before it throws the error, but that might be due to it running the "@storybook/nextjs" framework, which might be doing something for the front end that isn't factored into the build process. |
Found a different open issue #19340 that refers specifically to the problem I mentioned above. |
Describe the bug
On a Windows machine the staticDirs build with the expected structure:
Then when we run npm run start, Storybook starts and appears to be working fine, but none of the static assets can be found. When looking at the network it seems to be requesting the correct paths:
http://localhost:6006/assets/imgs/imgs_sub/image.png
http://localhost:6006/assets/svgs/icon.svg
But it's returning a 404. If I go direct to that path it also doesn't load.
main.js looks like this:
Debugging server-statics.js returns the following:
and for imgs
If I remove the dot from main.js, like so, then the build errors:
Error returned:
System
The text was updated successfully, but these errors were encountered: