Storybook: Fonts are not loaded correctly

Created on 18 Oct 2017  路  4Comments  路  Source: storybookjs/storybook

Hello:

I have an issue that fonts are not displayed. I have found that it is because the font files end up containing JS code. For example, here is what a font file (Roboto-Regular.4db8a3e8.ttf) contains:

module.exports = __webpack_public_path__ + "df7b648ce5356ea1ebce435b3459fd60.ttf";

The fonts are displayed on the project, but when I use Storybook with the same webpack.config, I have this issue. The webpack.config contains the rule required for the fonts:

{
  test: /\.(eot|ttf|woff|woff2)$/,
  loader: 'file-loader'
}

So I don't know what can be causing this issue, would appreciate any help.

Thank you

babel / webpack has workaround question / support

Most helpful comment

I have found a way to fix this issue. I have check the default config and it appears that there is already a loader specified for fonts, and the issue was probably because there were two loaders. In any case, by making sure that there is only one loader for fonts specified (the one in the default Storybook config) I was able to get rid of this issue.

All 4 comments

I have found a way to fix this issue. I have check the default config and it appears that there is already a loader specified for fonts, and the issue was probably because there were two loaders. In any case, by making sure that there is only one loader for fonts specified (the one in the default Storybook config) I was able to get rid of this issue.

Not sure this should have been closed without a fix. We lost a few hours on this

Do you have a fix for it @VincentCharpentier ?

@rwieruch Nothing ideal, I just ignored the issue until it is fixed.
Maybe you can try @ilya-pyatin 's solution of using only the default storybook webpack rule for fonts.
Let me know if you find something interesting, I'd be happy to fix that in my project too

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xogeny picture xogeny  路  3Comments

MrOrz picture MrOrz  路  3Comments

rpersaud picture rpersaud  路  3Comments

tlrobinson picture tlrobinson  路  3Comments

arunoda picture arunoda  路  3Comments