Skip to content
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

Storybook 4.0.0-alpha.2 with FontAwesome #3435

Closed
emiyake opened this issue Apr 17, 2018 · 9 comments
Closed

Storybook 4.0.0-alpha.2 with FontAwesome #3435

emiyake opened this issue Apr 17, 2018 · 9 comments

Comments

@emiyake
Copy link

emiyake commented Apr 17, 2018

If you are reporting a bug or requesting support, start here:

Bug or support request summary

I updated the storybook in my project and found out that SVG fonts are not loaded correctly by the default wepack.config.js.

I noticed that .svg extension was removed from the loader that deals with fonts in the #3221 commit:

 {
        test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2)(\?.*)?$/,
        loader: require.resolve('file-loader'),
        query: {
          name: 'static/media/[name].[hash:8].[ext]'
        }
      }

and svg-url-loader was added:

{
        test: /\.svg$/,
        loader: require.resolve('svg-url-loader')
      },

The problem is that when there is a third-party components are loaded from node_modules, such as FontAwesome, the .svg in the css gets converted, causing an error in the css:

@font-face {
  font-family: 'FontAwesome';
  src: url(/static/media/fontawesome-webfont.674f50d2.eot);
  src: url(/static/media/fontawesome-webfont.674f50d2.eot?#iefix&v=4.7.0) format('embedded-opentype'), 
url(/static/media/fontawesome-webfont.af7ae505.woff2) format('woff2'),
url(/static/media/fontawesome-webfont.fee66e71.woff) format('woff'),
url(/static/media/fontawesome-webfont.b06871f2.ttf) format('truetype'),
url("data:image/svg+xml,%3C?xml version='1.0' standalone='no'?%3E %3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' %3E %3Csvg%3E %3Cmetadata%3E Created by FontForge 20120731 at ...

screen shot 2018-04-17 at 15 49 15

It should be:

@font-face {
  font-family: 'FontAwesome';
  src: url(/static/media/fontawesome-webfont.674f50d2.eot);
  src: url(/static/media/fontawesome-webfont.674f50d2.eot?#iefix&v=4.7.0) format('embedded-opentype'),
url(/static/media/fontawesome-webfont.af7ae505.woff2) format('woff2'), 
url(/static/media/fontawesome-webfont.fee66e71.woff) format('woff'),
url(/static/media/fontawesome-webfont.b06871f2.ttf) format('truetype'),
url(/static/media/fontawesome-webfont.912ec66d.svg#fontawesomeregular)

The solution would be removing svg-url-loader from the default webpack.config.js and adding back the |svg test in this line.

@danielduan
Copy link
Member

does using url-loader not have this issue?

@emiyake
Copy link
Author

emiyake commented Apr 18, 2018

@danielduan This issue persists even with url-loader

@danielduan
Copy link
Member

@emiyake it's not caused by that PR then. while we try to provide a sensible webpack configuration, it's impossible to support everything. your best bet is to use the Full Control Mode and remove the svg-url-loader entry

same problem as #3450

@emiyake
Copy link
Author

emiyake commented Apr 20, 2018

I see. Wouldn't it make sense not to add svg-url-loader in the default configuration and add it with Extended Control Mode when needed, instead of forcing developers to remove it from the baseConfig?
My understanding of basic configuration is to have a minimum support and we should add additional loaders according to the project needs (just like when we add loaders such as typescript).

The current approach causes incompatibility with other packages, which could be avoided.

What doesn't make sense to me is to create a full control webpack to remove things, instead of adding new loaders.

@Hypnosphi
Copy link
Member

Makes sense to me @emiyake

@anthonymetzler
Copy link

I'm having a similar issue with Semantic UI...
"@storybook/react": "^4.0.0-alpha.2" will break all the FontAwesome icons baked into Semantic UI. It's affecting the npm package "semantic-ui-css" as well as a local version of the Semantic library I've built.

@emiyake
Copy link
Author

emiyake commented Apr 26, 2018

@anthonymetzler https://gist.github.com/emiyake/a1302eeca331cceaf129789bb0a6c216

@stale
Copy link

stale bot commented May 17, 2018

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label May 17, 2018
@stale
Copy link

stale bot commented Jun 16, 2018

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

@stale stale bot closed this as completed Jun 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants