Skip to content

Instantly share code, notes, and snippets.

@vamsiampolu
Created July 5, 2017 19:04
Show Gist options
  • Save vamsiampolu/144a05c1e2c139dacc1c75aaec311063 to your computer and use it in GitHub Desktop.
Save vamsiampolu/144a05c1e2c139dacc1c75aaec311063 to your computer and use it in GitHub Desktop.
Server rendering svg sprite loader
import sprite from 'svg-sprite-loader/runtime/sprite.build';
const spriteContent = sprite.stringify();
// Your express app goes here
// Good luck with the rest of the server rendered configuration
res.send(`
<!DOCTYPE html>
<head>
<!-- add all your stylesheets and other stuff here, use the styled-components plugin, that is very powerful -->
</head>
<body>
<!-- Icons YAY!! -->
${svg}
<!-- the whole point of server rendering -->
<div id="root">${app}</div>
</body>
`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment