PageSourceSearch

https://react-svgr.com/component---node-modules-smooth-doc-src-tem…-pages-docs-cli-mdx-45d412f0d4b44428481b.js

js react-svgr.com collected 2026-10-03 19:13:01 UTC 14,222 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[169],{92410:function(e,n,t){t.r(n),t.d(n,{default:function(){return s}});var a=t(67294),l=t(39626);function i(e){var n=Object.assign({h1:"h1",a:"a",div:"div",p:"p",h2:"h2",code:"code",pre:"pre",h3:"h3"},(0,l.ah)(),e.components);return a.createElement(a.Fragment,null,a.createElement(n.h1,{id:"command-line",style:{position:"relative"}},a.createElement(n.a,{href:"#command-line","aria-label":"command line permalink",className:"anchor before"},a.createElement(n.div,{dangerouslySetInnerHTML:{__html:'<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>'}})),"Command Line"),"\n",a.createElement(n.p,null,"Use SVGR from command line to transform a single file or a whole directory."),"\n",a.createElement("carbon-ad"),"\n",a.createElement(n.h2,{id:"install",style:{position:"relative"}},a.createElement(n.a,{href:"#install","aria-label":"install permalink",className:"anchor before"},a.createElement(n.div,{dangerouslySetInnerHTML:{__html:'<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>'}})),"Install"),"\n",a.createElement(n.p,null,"Depending you usage, you can install ",a.createElement(n.code,null,"@svgr/cli")," locally in your project:"),"\n",a.createElement(n.pre,null,a.createElement(n.code,{className:"language-sh"},"npm install --save-dev @svgr/cli\n# or use yarn\nyarn add --dev @svgr/cli\n")),"\n",a.createElement(n.p,null,"or use it on the fly using ",a.createElement(n.code,null,"npx @svgr/cli"),"."),"\n",a.createElement(n.h2,{id:"options",style:{position:"relative"}},a.createElement(n.a,{href:"#options","aria-label":"options permalink",className:"anchor before"},a.createElement(n.div,{dangerouslySetInnerHTML:{__html:'<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>'}})),"Options"),"\n",a.createElement(n.p,null,"All ",a.createElement(n.a,{href:"https://react-svgr.com/docs/options/"},"SVGR options")," are available from command line or in configuration. Command line options have precedence over config file options."),"\n",a.createElement(n.h2,{id:"transform-a-single-file",style:{position:"relative"}},a.createElement(n.a,{href:"#transform-a-single-file","aria-label":"transform a single file permalink",className:"anchor before"},a.createElement(n.div,{dangerouslySetInnerHTML:{__html:'<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>'}})),"Transform a single file"),"\n",a.createElement(n.h3,{id:"from-file",style:{position:"relative"}}
1,a.createElement(n.a,{href:"#from-file","aria-label":"from file permalink",className:"anchor before"},a.createElement(n.div,{dangerouslySetInnerHTML:{__html:'<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>'}})),"From file"),"\n",a.createElement(n.p,null,"Transforms a single file by specifying file as the single argument."),"\n",a.createElement(n.pre,null,a.createElement(n.code,{className:"language-sh"},"npx @svgr/cli -- icons/clock-icon.svg\n")),"\n",a.createElement(n.h3,{id:"from-standard-input",style:{position:"relative"}},a.createElement(n.a,{href:"#from-standard-input","aria-label":"from standard input permalink",className:"anchor before"},a.createElement(n.div,{dangerouslySetInnerHTML:{__html:'<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>'}})),"From standard input"),"\n",a.createElement(n.p,null,a.createElement(n.code,null,"@svgr/cli")," supports standard input, just redirect file contents using ",a.createElement(n.code,null,"<")," operator."),"\n",a.createElement(n.pre,null,a.createElement(n.code,{className:"language-sh"},"npx @svgr/cli < icons/clock-icon.svg\n")),"\n",a.createElement(n.h3,{id:"output-the-result-in-another-file",style:{position:"relative"}},a.createElement(n.a,{href:"#output-the-result-in-another-file","aria-label":"output the result in another file permalink",className:"anchor before"},a.createElement(n.div,{dangerouslySetInnerHTML:{__html:'<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>'}})),"Output the result in another file"),"\n",a.createElement(n.p,null,"You can easily create another file using ",a.createElement(n.code,null,">")," operator."),"\n",a.createElement(n.pre,null,a.createElement(n.code,{className:"language-sh"},"npx @svgr/cli -- icons/clock-icon.svg > dist/ClockIcon.js\n")),"\n",a.createElement(n.h2,{id:"transform-a-whole-directory",style:{position:"relative"}},a.createElement(n.a,{href:"#transform-a-whole-directory","aria-label":"transform a whole directory permalink",className:"anchor before"},a.createElement(n.div,{dangerouslySetInnerHTML:{__html:'<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>'}})),"Transform a whole directory"),"\n",a.createElement(n.p,null,"Transforms a whole directory using ",a.createElement(n.code,null,"--out-dir")," option. All SVG presents in this directory tree are transformed into React components."),"\n",a.createElement(n.pre,null,a.createElement(n.code,{className:"language-sh"},"# Usage: npx @svgr/cli [--out-dir dir] [--ignore-existing] [src-dir]\n$ npx @svgr/cli --out-dir dist -- icons\nicons/web/clock-icon.svg -> dist/web/ClockIcon.js\nicons/web/wifi-icon.svg -> dist/web/WifiIcon.js\nicons/spinner/cog-icon.svg -> dist/spinner/CogIcon.js\nicons/spinner/spinner-icon.svg -> dist/spinner/SpinnerIcon.js\n")),"\n",a.createElement(n.h3,{id:"avoid-replacing-existing-files",style:{position:"relative"}}
1,a.createElement(n.a,{href:"#avoid-replacing-existing-files","aria-label":"avoid replacing existing files permalink",className:"anchor before"},a.createElement(n.div,{dangerouslySetInnerHTML:{__html:'<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>'}})),"Avoid replacing existing files"),"\n",a.createElement(n.p,null,"Even if it is not recommended, you may be tempted to modify generated files. If you do so, you should use the ",a.createElement(n.code,null,"--ignore-existing")," option to avoid replacing existing files."),"\n",a.createElement(n.pre,null,a.createElement(n.code,{className:"language-sh"},"npx @svgr/cli --out-dir dist --ignore-existing -- icons\n")),"\n",a.createElement(n.h3,{id:"use-a-different-filename-case",style:{position:"relative"}},a.createElement(n.a,{href:"#use-a-different-filename-case","aria-label":"use a different filename case permalink",className:"anchor before"},a.createElement(n.div,{dangerouslySetInnerHTML:{__html:'<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>'}})),"Use a different filename case"),"\n",a.createElement(n.p,null,'By default, filenames uses "PascalCase", you can specify a different case for generated files using ',a.createElement(n.code,null,"--filename-case")," option."),"\n",a.createElement(n.pre,null,a.createElement(n.code,{className:"language-sh"},"npx @svgr/cli --out-dir dist --filename-case kebab -- icons\n")),"\n",a.createElement(n.h3,{id:"disable-index-generation",style:{position:"relative"}},a.createElement(n.a,{href:"#disable-index-generation","aria-label":"disable index generation permalink",className:"anchor before"},a.createElement(n.div,{dangerouslySetInnerHTML:{__html:'<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>'}})),"Disable index generation"),"\n",a.createElement(n.p,null,"By default an index is generated, giving you opportunity to import all your components from the directory. If you does not want auto-generated index, turn it off using ",a.createElement(n.code,null,"--no-index")," option."),"\n",a.createElement(n.pre,null,a.createElement(n.code,{className:"language-sh"},"npx @svgr/cli --out-dir dist --no-index -- icons\n")),"\n",a.createElement(n.h3,{id:"use-a-custom-index-template",style:{position:"relative"}},a.createElement(n.a,{href:"#use-a-custom-index-template","aria-label":"use a custom index template permalink",className:"anchor before"},a.createElement(n.div,{dangerouslySetInnerHTML:{__html:'<svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>'}})),"Use a custom index template"),"\n",a.createElement(n.p,null,"Advanced use cases could lead you to customize the index template. The ",a.createElement(n.code,null,"--index-template <template>")," argument let you specify a custom one."),"\n",a.createElement(n.pre,null,a.createElement(n.code,{className:"language-js"},"// index-template.js\nconst path = require('path')\n\nfunction defaultIndexTemplate(filePaths) {\n  const exportEntries = filePaths.map(({ path: filePath, originalPath }) =>
1 {\n    const basename = path.basename(filePath, path.extname(filePath))\n    const exportName = /^\\d/.test(basename) ? `Svg${basename}` : basename\n    return `export { default as ${exportName} } from './${basename}'`\n  })\n  return exportEntries.join('\\n')\n}\n\nmodule.exports = defaultIndexTemplate\n")),"\n",a.createElement(n.pre,null,a.createElement(n.code,{className:"language-sh"},"npx @svgr/cli  --out-dir dist --index-template index-template.js -- icons\n")))}var r=function(e){void 0===e&&(e={});var n=Object.assign({},(0,l.ah)(),e.components).wrapper;return n?a.createElement(n,e,a.createElement(i,e)):i(e)};function c(e){return e.children}function s(e){return a.createElement(c,e,a.createElement(r,e))}}}]);
2//# sourceMappingURL=component---node-modules-smooth-doc-src-templates-doc-js-content-file-path-opt-build-repo-website-pages-docs-cli-mdx-45d412f0d4b44428481b.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.