lhl 6ff0e96ad3 8-4-1 há 1 ano atrás
..
build 6ff0e96ad3 8-4-1 há 1 ano atrás
README.md 6ff0e96ad3 8-4-1 há 1 ano atrás
main.js 6ff0e96ad3 8-4-1 há 1 ano atrás
webpack.config.js 6ff0e96ad3 8-4-1 há 1 ano atrás

README.md

Server side rendering example

When webpack config target option is 'node' svg-sprite-loader will use isomorphic runtime sprite module.

Demo

Input

main.js

import symbol from '../assets/twitter.svg';

// Import sprite instance which already contains twitter logo required above
import sprite from 'svg-sprite-loader/runtime/sprite.build';

// Render sprite
const spriteContent = sprite.stringify();

const pageContent = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
${spriteContent}

<svg viewBox="${symbol.viewBox}">
  <use xlink:href="#${symbol.id}"></use>
</svg>
</body>
</html>
`;

console.log(pageContent);

Output