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

Icons not appearing in gatsbyJS #2

Open
kavimaluskam opened this issue Jan 26, 2018 · 3 comments
Open

Icons not appearing in gatsbyJS #2

kavimaluskam opened this issue Jan 26, 2018 · 3 comments

Comments

@kavimaluskam
Copy link

When i import the icon, it eventually vender the source string:
data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjggMTI4Ij48ZyBmaWxsPSIjNjFEQU....... in my web page,

While i tried to copy the svg source code like: https://github.com/fpoumian/react-devicon/blob/master/src/components/docker/original/DockerOriginal.svg
and render it in my project and it works.... any idea about this?

@vinaypuppal
Copy link

@kavimaluskam You need to configure Gatsby with a Webpack loader that can load inline SVGs

  • Install https://github.com/webpack-contrib/raw-loader
  • And use this config
    if (
    ['develop', 'develop-html', 'build-html', 'build-javascript'].includes(
    stage
    )
    ) {
    // Remove svg from url-loader config
    config.loader(`url-loader`, {
    test: /\.(jpg|jpeg|png|gif|mp4|webm|wav|mp3|m4a|aac|oga)(\?.*)?$/,
    loader: `url`,
    query: {
    limit: 10000,
    name: `static/[name].[hash:8].[ext]`,
    },
    })
    config.loader('raw-loader', {
    test: /\.svg$/,
    loader: 'raw-loader',
    })
    }
    return config

@thidasapankaja
Copy link

@vinaypuppal I got the same issue and followed your answer, but still the same issue. It doesn't display the icon, but only the svg source like data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjggMTI4Ij48ZyBmaWxsPSIjNjFEQU....... in
Any fix ?

@Pranav2612000
Copy link

Same issue here were you able to fix it? I tried using gatsby-plugin-svgr and gatsby-plugin-react-svg but still wasn't able to fix the issue. Using gatsby-plugin-react-svg I received the following error: TypeError: Object.keys(...).filter(...).reduce(...).trim is not a function. Is there any way to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants