How to use the @svgr/core.default.sync function in @svgr/core

To help you get started, we’ve selected a few @svgr/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kristerkari / react-native-svg-transformer / index.js View on Github external
module.exports.transform = function(src, filename, options) {
  if (typeof src === "object") {
    // handle RN >= 0.46
    ({ src, filename, options } = src);
  }

  if (filename.endsWith(".svg") || filename.endsWith(".svgx")) {
    var config = resolveConfig.sync(resolveConfigDir(filename));
    var svgrConfig = config
      ? Object.assign({}, defaultsvgrConfig, config)
      : defaultsvgrConfig;
    var jsCode = svgr.sync(src, svgrConfig);
    return upstreamTransformer.transform({
      src: fixRenderingBugs(jsCode),
      filename,
      options
    });
  }
  return upstreamTransformer.transform({ src, filename, options });
};
github commercetools / ui-kit / scripts / generate-icon-exports.js View on Github external
files.forEach(fileName => {
      const fileNameWithoutExtension = path.basename(fileName, iconFileExt);
      const componentName = upperFirst(camelCase(fileNameWithoutExtension));

      const svgCode = fs.readFileSync(fileName, 'UTF-8');
      const jsCode = svgr.sync(
        svgCode,
        {
          icon: false,
          svgoConfig: {
            plugins: [
              { removeViewBox: false },
              { prefixIds: true },
              // same result as rollup plugin
              { prefixIds: { prefix: fileNameWithoutExtension } },

              // Keeps ID's of svgs so they can be targeted with CSS
              { cleanupIDs: false },
            ],
          },
          // same as the rollup plugin
          plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx'],