Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 });
};
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'],