Closed ahaywood closed 1 day ago
Get the same error (but due to markdown file)
import helpContent from './Help.md?raw'
This works in the normal dev server, not storybook.
if I comment out that line and replace with
const helpContent = 'test'
it works
Does Storybook still use webpack? if so, does the loader need to be configured.
Update to my previous comment. Note: my problem is with loading a markdown file (but I believe the fonts issue is similar)
As suspected my storybook is still using webpack (even though my project is vite). Redwood version 6.1.0
My fix (workaround)
Setup additional webpack configuration
edit the created web/config/webpack.config.js file
In my case, I also had to add the raw-loader package
EXTRA CREDIT I found the redwood stats functionality command that I had not used before. Might be useful to track down webpack issues and easily determine if your new configuration is working.
yarn rw build --stats
I recently looked at this and at least for Amy's cause, it seems like it's because of new lines in the properties using the url
function:
@font-face {
font-family: "My font";
/* 👇 The new lines here may cause an error */
src: url("/fonts/myFont/MyFont.ttf") format("truetype"),
url("/fonts/myFont/myfontbold.woff") format("woff"),
url("/fonts/myFont/myfontregular.woff2") format("woff2");
}
When I got rid of those new lines, the error went away:
@font-face {
font-family: "My font";
src: url("/fonts/myFont/MyFont.ttf") format("truetype"), url("/fonts/myFont/myfontbold.woff") format("woff"), url("/fonts/myFont/myfontregular.woff2") format("woff2");
}
So, there's one possible workaround.
@ahaywood Can you confirm that @rkmitra1's and/or @jtoar's workarounds work for you with your font?
@jtoar 's workaround did work for me! I've just been sticking the url
on a single line.
This seems to have bee resolved. 🙌
What's not working?
Storybook is erroring out if there's a custom
@font-face
block within my index.cssHere's a Loom video demonstrating: https://www.loom.com/share/d75b96e132cc44219bb44fa503d5dd73
My fonts are within a
public/fonts
directory, which is aligned with the documentation.A few notes:
How do we reproduce the bug?
public/fonts
@font-face
block. (Here's mine):Run
yarn rw storybook
Everything seems to be running fine in dev
yarn rw dev
What's your environment? (If it applies)
Are you interested in working on this?