Importing font files (*.woff, *.ttf)
See original GitHub issueDescribe the bug
Loading fonts seems to be failing with:
ModuleBuildError: Module build failed (from ./node_modules/storybook-addon-next/dist/images/next-image-loader-stub.js):
TypeError: unsupported file type: undefined (file: undefined)
at lookup (/Users/.../node_modules/image-size/dist/index.js:52:11)
at imageSize (/Users/.../node_modules/image-size/dist/index.js:104:16)
Webpack config shows that the font is being loaded via next-image-loader-stub:
{
test: /\.(svg|ico|jpg|jpeg|png|apng|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\?.*)?$/,
use: [
{
loader: '/Users/.../node_modules/storybook-addon-next/dist/images/next-image-loader-stub.js',
options: { filename: 'static/media/[path][name][ext]' }
}
]
},
Perhaps it’s because font files won’t have a width and height?
https://github.com/RyanClementsHax/storybook-addon-next/blob/6583c2080386f72fdebc49ff93a2b8262d1219bc/src/images/next-image-loader-stub.ts#L24
Just guessing… Would love to hear your insights. Thanks!
Your minimal, reproducible example
http://forking.example.on.codesandbox.fails.to.build
Steps to reproduce
- add a font static asset
- add css that imports font file
- storybook start fails
Expected behavior
I expected static file imports to work as before, but next-image-loader-stub seems to be breaking.
How often does this bug happen?
No response
Screenshots or Videos
No response
Platform
- OS: MacOS X
- Node 16
storybook-addon-next version
v1.3.1
Additional context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
The BEST way to import and upload custom fonts into ...
The best and most SEO optimised way to import and upload your custom ... Find the font files (.woff or .woff2) and upload...
Read more >Understanding font file formats(ttf, otf, woff, etc)
Understanding font file formats(ttf, otf, woff, etc) ... unpack and use the css provided by them to get a kickstart on importing the...
Read more >How to convert WOFF font format to TTF on Windows 11/10
Convert WOFF font to TTF file format using this free online font converter tool or command line so that you can use it...
Read more >How to use @font-face in CSS
Stands for: OpenType Font and TrueType Font. The WOFF format was initially created as a reaction to OTF and TTF, in part, because...
Read more >Understanding of Font Formats: TTF, OTF, WOFF, EOT & SVG
Compression and subsetting make the font files smaller. ... WOFF is basically OTF or TTF with metadata and compression supported by all major...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thanks Ryan! Fantastic work! I noticed a different, smaller issue as well. Will open another ticket when I get a chance.
🎉 This issue has been resolved in version 1.4.1 🎉
The release is available on:
Your semantic-release bot 📦🚀